Skip to content

Commit

Permalink
Rename from jenkinsx to api4jenkins (#5)
Browse files Browse the repository at this point in the history
* rename
  • Loading branch information
joelee2012 authored Oct 24, 2020
1 parent d43f71e commit 0bd78d5
Show file tree
Hide file tree
Showing 34 changed files with 115 additions and 115 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Build Status](https://travis-ci.com/joelee2012/jenkinsx.svg?branch=master)](https://travis-ci.com/joelee2012/jenkinsx)
[![Coverage Status](https://coveralls.io/repos/github/joelee2012/jenkinsx/badge.svg?branch=master)](https://coveralls.io/github/joelee2012/jenkinsx?branch=master)
[![Build Status](https://travis-ci.com/joelee2012/api4jenkins.svg?branch=master)](https://travis-ci.com/joelee2012/api4jenkins)
[![Coverage Status](https://coveralls.io/repos/github/joelee2012/api4jenkins/badge.svg?branch=master)](https://coveralls.io/github/joelee2012/api4jenkins?branch=master)

# Jenkinsx
# api4jenkins

[Jenkinsx](https://github.com/joelee2012/jenkinsx) is an object oriented [Python](https://www.python.org/) project that provides access to the [Jenkins](https://jenkins.io/) [Remote access API](https://wiki.jenkins.io/display/JENKINS/Remote+access+API) programmatically. It assiciates/constructs python class/object with Jenkins's items and JSON API. It provides but not limits functionalities to control Job, Build, Node, View, Credential, BuildQueue, Plugins and System:
[api4jenkins](https://github.com/joelee2012/api4jenkins) is an object oriented [Python](https://www.python.org/) project that provides access to the [Jenkins](https://jenkins.io/) [Remote access API](https://wiki.jenkins.io/display/JENKINS/Remote+access+API) programmatically. It assiciates/constructs python class/object with Jenkins's items and JSON API. It provides but not limits functionalities to control Job, Build, Node, View, Credential, BuildQueue, Plugins and System:
- get/delete/create/move/rename/copy/build/enable/disable job or folder, iterate children jobs with depth, folder based views/credentials functionalities
- get/iterate builds of project, stop/term/kill build, get progressive console output.
- get/delete/create/iterate views for jenkins or folder. add/remove jobs to/from view.
Expand All @@ -18,13 +18,13 @@
# Installation

```bash
pip install jenkinsx
pip install api4jenkins
```

# Quick start

```python
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> j.version
'2.176.2'
Expand Down Expand Up @@ -66,7 +66,7 @@ False
>>> build.result
'SUCCESS'
```
More usage can be found in [Documentation](https://jenkinsx.readthedocs.io/en/latest/)
More usage can be found in [Documentation](https://api4jenkins.readthedocs.io/en/latest/)

# Contributing

Expand Down
26 changes: 13 additions & 13 deletions jenkinsx/__init__.py → api4jenkins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Jenkins(Item):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> print(j)
<Jenkins: http://127.0.0.1:8080/>
Expand Down Expand Up @@ -67,7 +67,7 @@ def get_job(self, full_name):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> job = j.get_job('freestylejob')
>>> print(job)
Expand All @@ -84,7 +84,7 @@ def iter_jobs(self, depth=0):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> for job in j.iter_jobs():
... print(job)
Expand All @@ -102,7 +102,7 @@ def create_job(self, full_name, xml):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> xml = """<?xml version='1.1' encoding='UTF-8'?>
... <project>
Expand All @@ -129,7 +129,7 @@ def copy_job(self, full_name, dest):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> j.copy_job('folder/freestylejob', 'newjob')
>>> j.get_job('folder/newjob')
Expand All @@ -146,7 +146,7 @@ def delete_job(self, full_name):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> job = j.get_job('freestylejob')
>>> print(job)
Expand All @@ -169,7 +169,7 @@ def build_job(self, full_name, parameters=None):
Usage::
>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> item = j.build_job('freestylejob')
>>> import time
Expand Down Expand Up @@ -238,13 +238,13 @@ def crumb(self):
@property
def system(self):
'''An object for managing system operation.
see :class:`System <jenkinsx.system.System>`'''
see :class:`System <api4jenkins.system.System>`'''
return System(self, self.url)

@property
def plugins(self):
'''An object for managing plugins.
see :class:`PluginsManager <jenkinsx.plugin.PluginsManager>`'''
see :class:`PluginsManager <api4jenkins.plugin.PluginsManager>`'''
return PluginsManager(self, f'{self.url}pluginManager/')

@property
Expand All @@ -255,26 +255,26 @@ def version(self):
@property
def credentials(self):
'''An object for managing credentials.
see :class:`Credentials <jenkinsx.credential.Credentials>`'''
see :class:`Credentials <api4jenkins.credential.Credentials>`'''
return Credentials(self,
f'{self.url}credentials/store/system/domain/_/')

@property
def views(self):
'''An object for managing views of main window.
see :class:`Views <jenkinsx.view.Views>`'''
see :class:`Views <api4jenkins.view.Views>`'''
return Views(self)

@property
def nodes(self):
'''An object for managing nodes.
see :class:`Nodes <jenkinsx.node.Nodes>`'''
see :class:`Nodes <api4jenkins.node.Nodes>`'''
return Nodes(self, f'{self.url}computer/')

@property
def queue(self):
'''An object for managing build queue.
see :class:`Queue <jenkinsx.queue.Queue>`'''
see :class:`Queue <api4jenkins.queue.Queue>`'''
return Queue(self, f'{self.url}queue/')


Expand Down
4 changes: 2 additions & 2 deletions jenkinsx/__version__.py → api4jenkins/__version__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
__version__ = '1.0'
__title__ = 'jenkinsx'
__title__ = 'api4jenkins'
__description__ = 'Jenkins REST API client'
__url__ = 'https://github.com/joelee2012/jenkinsx'
__url__ = 'https://github.com/joelee2012/api4jenkins'
__author__ = 'Joe Lee'
__author_email__ = '[email protected]'
__license__ = 'Apache 2.0'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion jenkinsx/item.py → api4jenkins/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _new_instance_by_item(self, module, item):
if not hasattr(module, class_name):
raise AttributeError(f'{module} has no class {class_name}, '
'Patch new class with'
' jenkinsx._patch_to')
' api4jenkins._patch_to')
_class = getattr(module, class_name)
return _class(self.jenkins, item['url'])

Expand Down
6 changes: 3 additions & 3 deletions jenkinsx/job.py → api4jenkins/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _get_build_by_key(key):
item = self.api_json(tree=f'{key}[url]')[key]
if item is None:
return None
return self._new_instance_by_item('jenkinsx.build', item)
return self._new_instance_by_item('api4jenkins.build', item)

for key in ['firstBuild', 'lastBuild', 'lastCompletedBuild',
'lastFailedBuild', 'lastStableBuild', 'lastUnstableBuild',
Expand All @@ -123,7 +123,7 @@ def build(self, parameters=None):
def get_build(self, number):
for item in self.api_json(tree='builds[number,url]')['builds']:
if int(number) == int(item['number']):
return self._new_instance_by_item('jenkinsx.build', item)
return self._new_instance_by_item('api4jenkins.build', item)
return None

def iter_builds(self):
Expand All @@ -146,7 +146,7 @@ def building(self):

def __iter__(self):
for item in self.api_json(tree='builds[number,url]')['builds']:
yield self._new_instance_by_item('jenkinsx.build', item)
yield self._new_instance_by_item('api4jenkins.build', item)


class WorkflowJob(Project):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions jenkinsx/node.py → api4jenkins/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def iter_builds(self):
tree = 'computer[oneOffExecutors[currentExecutable[url]]]'
for computer in self.api_json(tree, 2)['computer']:
for executor in computer.get('oneOffExecutors'):
yield self._new_instance_by_item('jenkinsx.build',
yield self._new_instance_by_item('api4jenkins.build',
executor['currentExecutable'])

def __iter__(self):
Expand All @@ -74,7 +74,7 @@ def disable(self, msg=''):
def iter_builds(self):
tree = 'oneOffExecutors[currentExecutable[url]]'
for executor in self.api_json(tree, 2)['oneOffExecutors']:
yield self._new_instance_by_item('jenkinsx.build',
yield self._new_instance_by_item('api4jenkins.build',
executor['currentExecutable'])


Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions jenkinsx/queue.py → api4jenkins/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_job(self):
if self._class.endswith('$BuildableItem'):
return self.get_build().get_job()
task = self.api_json(tree='task[url]')['task']
return self._new_instance_by_item('jenkinsx.job', task)
return self._new_instance_by_item('api4jenkins.job', task)

def get_build(self):
if not self._build:
Expand All @@ -53,7 +53,7 @@ def get_build(self):
if _class.endswith('$LeftItem'):
executable = self.api_json('executable[url]')['executable']
self._build = self._new_instance_by_item(
'jenkinsx.build', executable)
'api4jenkins.build', executable)
elif _class.endswith(('$BuildableItem', '$WaitingItem')):
for build in self.jenkins.nodes.iter_builds():
if int(build.queue_id) + 1 == self.id:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions jenkinsx/view.py → api4jenkins/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class View(Item, ConfigrationMix, DeletionMix):
def get_job(self, name):
for item in self.api_json(tree='jobs[name,url]')['jobs']:
if name == item['name']:
return self._new_instance_by_item('jenkinsx.job', item)
return self._new_instance_by_item('api4jenkins.job', item)
return None

def __iter__(self):
for item in self.api_json(tree='jobs[name,url]')['jobs']:
yield self._new_instance_by_item('jenkinsx.job', item)
yield self._new_instance_by_item('api4jenkins.job', item)

def include(self, name):
self.handle_req('POST', 'addJobToView', params={'name': name})
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sys.path.insert(0, os.path.abspath('../../'))
# -- Project information -----------------------------------------------------

project = 'Jenkinsx'
project = 'api4jenkins'
copyright = '2020, Joe Lee'
author = 'Joe Lee'

Expand Down
8 changes: 4 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.. Jenkinsx documentation master file, created by
.. api4jenkins documentation master file, created by
sphinx-quickstart on Mon Dec 16 20:16:12 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Jenkinsx's documentation!
Welcome to api4jenkins's documentation!
====================================


`Jenkinsx <https://github.com/joelee2012/jenkinsx>`_ is an object oriented `Python <https://www.python.org/>`_ project that provides access to the `Jenkins <https://jenkins.io/>`_ `Remote access API <https://wiki.jenkins.io/display/JENKINS/Remote+access+API>`_ programmatically. It assiciates/constructs python class/object with Jenkins's items and JSON API.
`api4jenkins <https://github.com/joelee2012/api4jenkins>`_ is an object oriented `Python <https://www.python.org/>`_ project that provides access to the `Jenkins <https://jenkins.io/>`_ `Remote access API <https://wiki.jenkins.io/display/JENKINS/Remote+access+API>`_ programmatically. It assiciates/constructs python class/object with Jenkins's items and JSON API.

------------------------------

Expand All @@ -31,7 +31,7 @@ Quick start
Here is an example to create job and start build, obtain build object the queue item, and pull progressive output until its completion, and obtain the build status.


>>> from jenkinsx import Jenkins
>>> from api4jenkins import Jenkins
>>> j = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> j.version
'2.176.2'
Expand Down
28 changes: 14 additions & 14 deletions docs/source/user/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,72 @@
API reference
=============

.. automodule:: jenkinsx
.. automodule:: api4jenkins
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.job
.. automodule:: api4jenkins.job
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.build
.. automodule:: api4jenkins.build
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.queue
.. automodule:: api4jenkins.queue
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.credential
.. automodule:: api4jenkins.credential
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.node
.. automodule:: api4jenkins.node
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.plugin
.. automodule:: api4jenkins.plugin
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.view
.. automodule:: api4jenkins.view
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.system
.. automodule:: api4jenkins.system
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.user
.. automodule:: api4jenkins.user
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.item
.. automodule:: api4jenkins.item
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.mix
.. automodule:: api4jenkins.mix
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.requester
.. automodule:: api4jenkins.requester
:members:
:undoc-members:
:inherited-members:

.. automodule:: jenkinsx.exceptions
.. automodule:: api4jenkins.exceptions
:members:
:undoc-members:
:inherited-members:
Loading

0 comments on commit 0bd78d5

Please sign in to comment.