Source code for api4jenkins.view

# encoding: utf-8

from .item import AsyncItem, Item
from .mix import (AsyncConfigurationMixIn, AsyncDeletionMixIn,
                  AsyncDescriptionMixIn, ConfigurationMixIn,
                  DeletionMixIn, DescriptionMixIn)


[docs] class Views(Item): ''' classdocs ''' def __init__(self, owner): ''' Constructor ''' self.owner = owner super().__init__(owner.jenkins, owner.url)
[docs] def get(self, name): for item in self.api_json(tree='views[name,url]')['views']: if name == item['name']: return self._new_item(__name__, item) return None
[docs] def create(self, name, xml): self.handle_req('POST', 'createView', params={'name': name}, headers=self.headers, content=xml)
def __iter__(self): for item in self.api_json(tree='views[name,url]')['views']: yield self._new_item(__name__, item)
[docs] class View(Item, ConfigurationMixIn, DescriptionMixIn, DeletionMixIn):
[docs] def get(self, name): for item in self.api_json(tree='jobs[name,url]')['jobs']: if name == item['name']: return self._new_item('api4jenkins.job', item) return None
def __iter__(self): for item in self.api_json(tree='jobs[name,url]')['jobs']: yield self._new_item('api4jenkins.job', item)
[docs] def include(self, name): self.handle_req('POST', 'addJobToView', params={'name': name})
[docs] def exclude(self, name): self.handle_req('POST', 'removeJobFromView', params={'name': name})
[docs] class AllView(View): def __init__(self, jenkins, url): # name of all view for jenkins is 'all', but for folder is 'All' name = 'view/all' if jenkins.url == url else 'view/All' super().__init__(jenkins, url + name)
[docs] class MyView(View): pass
[docs] class ListView(View): pass
[docs] class Dashboard(View): pass
[docs] class NestedView(View): @property def views(self): return Views(self)
[docs] class SectionedView(View): pass
[docs] class AsyncViews(AsyncItem): ''' classdocs ''' def __init__(self, owner): ''' Constructor ''' self.owner = owner super().__init__(owner.jenkins, owner.url)
[docs] async def get(self, name): data = await self.api_json(tree='views[name,url]') for item in data['views']: if name == item['name']: return self._new_item(__name__, item) return None
[docs] async def create(self, name, xml): await self.handle_req('POST', 'createView', params={'name': name}, headers=self.headers, content=xml)
async def __aiter__(self): data = await self.api_json(tree='views[name,url]') for item in data['views']: yield self._new_item(__name__, item)
[docs] class AsyncView(AsyncItem, AsyncConfigurationMixIn, AsyncDescriptionMixIn, AsyncDeletionMixIn):
[docs] async def get(self, name): data = await self.api_json(tree='jobs[name,url]') for item in data['jobs']: if name == item['name']: return self._new_item('api4jenkins.job', item) return None
async def __aiter__(self): data = await self.api_json(tree='jobs[name,url]') for item in data['jobs']: yield self._new_item('api4jenkins.job', item)
[docs] async def include(self, name): await self.handle_req('POST', 'addJobToView', params={'name': name})
[docs] async def exclude(self, name): await self.handle_req('POST', 'removeJobFromView', params={'name': name})
[docs] class AsyncAllView(AsyncView): def __init__(self, jenkins, url): # name of all view for jenkins is 'all', but for folder is 'All' name = 'view/all' if jenkins.url == url else 'view/All' super().__init__(jenkins, url + name)
[docs] class AsyncMyView(AsyncView): pass
[docs] class AsyncListView(AsyncView): pass
[docs] class AsyncDashboard(AsyncView): pass
[docs] class AsyncNestedView(AsyncView): @property def views(self): return AsyncViews(self)
[docs] class AsyncSectionedView(AsyncView): pass