yagocd.resources package¶
Submodules¶
yagocd.resources.agent module¶
-
class
yagocd.resources.agent.
AgentEntity
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
-
class
yagocd.resources.agent.
AgentManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The agents API allows users with administrator role to manage agents.
Versionadded: 15.2.0. Warning: Please note that this API requires using v4 of the API using Accept: application/vnd.go.cd.v4+json -
ACCEPT_HEADER
= 'application/vnd.go.cd.v4+json'¶
-
RESOURCE_PATH
= '{base_api}/agents'¶
-
VERSION_TO_ACCEPT_HEADER
= {'16.7.0': 'application/vnd.go.cd.v2+json', '16.9.0': 'application/vnd.go.cd.v3+json', '16.1.0': 'application/vnd.go.cd.v1+json'}¶
-
delete
(*args, **kwargs)[source]¶ Deletes an agent.
Versionadded: 15.2.0. Parameters: uuid – uuid of the agent. Returns: a message confirmation if the agent was deleted.
-
dict
(*args, **kwargs)[source]¶ Wrapper for list() method, that transforms founded agents to dictionary by uuid key.
Returns: dictionary of agents with uuid as a key and agent as a value. Return type: dict[str, yagocd.resources.agent.AgentEntity]
-
get
(*args, **kwargs)[source]¶ Gets an agent by its unique identifier (uuid).
Versionadded: 15.2.0. Parameters: uuid – uuid of the agent Returns: Agent entity. Return type: yagocd.resources.agent.AgentEntity
-
job_history
(*args, **kwargs)[source]¶ Lists the jobs that have executed on an agent.
Versionadded: 14.3.0.
Parameters: - uuid – uuid of the agent.
- offset – number of jobs to be skipped.
Returns: an array of
yagocd.resources.job.JobInstance
along with the job transitions.Return type: list of yagocd.resources.job.JobInstance
-
list
(*args, **kwargs)[source]¶ Lists all available agents, these are agents that are present in the <agents/> tag inside cruise-config.xml and also agents that are in Pending state awaiting registration.
Versionadded: 15.2.0. Returns: an array of agents. Return type: list of yagocd.resources.agent.AgentEntity
-
yagocd.resources.artifact module¶
-
class
yagocd.resources.artifact.
Artifact
(session, data)[source]¶ Bases:
yagocd.resources.Base
Class, representing artifact of the build.
It could be one of file or folder.
-
PART_COUNT
= 5¶
-
SEP
= '/'¶
-
fetch
()[source]¶ Method for getting artifact’s content. Could only be applicable for file type.
Returns: content of the artifact.
-
job_name
¶
-
path
¶
-
pipeline_counter
¶
-
pipeline_name
¶
-
stage_counter
¶
-
stage_name
¶
-
walk
(topdown=True)[source]¶ Artifact tree generator - analogue of os.walk.
Parameters: topdown – if is True or not specified, directories are scanned from top-down. If topdown is set to False, directories are scanned from bottom-up. :rtype: collections.Iterator[
(str, list[yagocd.resources.artifact.Artifact], list[yagocd.resources.artifact.Artifact])]
-
-
class
yagocd.resources.artifact.
ArtifactManager
(session, pipeline_name=None, pipeline_counter=None, stage_name=None, stage_counter=None, job_name=None)[source]¶ Bases:
yagocd.resources.BaseManager
,yagocd.util.RequireParamMixin
The artifacts API allows users to query and create artifacts of a job.
Versionadded: 14.3.0. -
FILES_FIELD
= 'files'¶
-
FILE_TYPE
= 'file'¶
-
FOLDER_TYPE
= 'folder'¶
-
NAME_FIELD
= 'name'¶
-
PATH_PARAMETERS
= ['pipeline_name', 'pipeline_counter', 'stage_name', 'stage_counter', 'job_name']¶
-
RESOURCE_PATH
= '{base_api}/files/{pipeline_name}/{pipeline_counter}/{stage_name}/{stage_counter}/{job_name}'¶
-
TYPE_FIELD
= 'type'¶
-
append
(*args, **kwargs)[source]¶ Appends a local file to an existing artifact.
Versionadded: 14.3.0.
Parameters: - path – path to the file within job directory.
- filename – the contents file to be uploaded.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: an acknowledgement that the file was created.
-
create
(*args, **kwargs)[source]¶ Uploads a local file as an artifact.
Versionadded: 14.3.0.
Parameters: - path – path to the file within job directory.
- filename – the contents file to be uploaded.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: an acknowledgement that the file was created.
-
directory
(*args, **kwargs)[source]¶ Gets an artifact directory by its path.
Versionadded: 14.3.0.
Note: The path can be a nested directory for e.g. target/dist.zip
Warning: Since it may take an undetermined amount of time to compress a directory, the server may return a 202 Accepted code to indicate that it is compressing the requested directory. Users are expected to poll the url every few seconds to check if the directory is available.
Parameters: - path – path to directory.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: - A status code 202 Accepted to acknowledge your request to compress the contents of the requested directory.
- The requested directory contents in the form of a zip file.
-
directory_wait
(*args, **kwargs)[source]¶ Gets an artifact directory by its path. This method wraps original directory method, adding timeout to wait for directory to be available.
Versionadded: 14.3.0.
Parameters: - path – path to directory.
- timeout – timeout in seconds to wait for directory.
- backoff – backoff value.
- max_wait – maximum wait amount.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: The requested directory contents in the form of a zip file.
-
file
(*args, **kwargs)[source]¶ Gets an artifact file by its path.
Versionadded: 14.3.0.
Note: The path_to_file can be a nested file for e.g. dist/foobar-widgets-1.2.0.jar.
Parameters: - path – path to the file.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: the contents of the file you requested.
-
list
(*args, **kwargs)[source]¶ Lists all available artifacts in a job.
Versionadded: 14.3.0.
Parameters: - pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: An array of
yagocd.resources.artifact.Artifact
.Return type: list of yagocd.resources.artifact.Artifact
-
walk
(*args, **kwargs)[source]¶ Artifact tree generator - analogue of os.walk.
Parameters: - top – root path, from which traversal would be started.
- topdown – if is True or not specified, directories are scanned
from top-down. If topdown is set to False, directories are scanned from bottom-up. :param pipeline_name: name of the pipeline. :param pipeline_counter: pipeline counter. :param stage_name: name of the stage. :param stage_counter: stage counter. :param job_name: name of the job. :rtype: collections.Iterator[
(str, list[yagocd.resources.artifact.Artifact], list[yagocd.resources.artifact.Artifact])]
-
yagocd.resources.configuration module¶
-
class
yagocd.resources.configuration.
ConfigurationManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The configuration API allows users with administration role to view and manage configuration.
Versionadded: 14.3.0. -
ADMIN_RESOURCE_PATH
= '{base_api}/admin/config'¶
-
RESOURCE_PATH
= '{base_api}/config'¶
-
config
(*args, **kwargs)[source]¶ Gets the current configuration file.
Versionadded: 14.3.0. Parameters: md5 – md5 sum of config to get. If not given, current will be returned. Returns: the contents of the configuration file.
-
yagocd.resources.environment module¶
-
class
yagocd.resources.environment.
EnvironmentConfig
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
-
class
yagocd.resources.environment.
EnvironmentManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The environment config API allows users with administrator role to manage environment config.
Versionadded: 16.7.0. -
RESOURCE_PATH
= '{base_api}/admin/environments'¶
-
create
(*args, **kwargs)[source]¶ Creates an environment.
Parameters: config – new environment configuration. Return type: yagocd.resources.environment.EnvironmentConfig
-
delete
(*args, **kwargs)[source]¶ Deletes an environment.
Parameters: name – name of the environment to delete. Returns: A message confirmation if the environment was deleted. Return type: str
-
get
(*args, **kwargs)[source]¶ Gets environment by the given name.
Parameters: name – name of the environment to fetch. Return type: yagocd.resources.environment.EnvironmentConfig
-
list
(*args, **kwargs)[source]¶ Lists all available environments.
Return type: list of yagocd.resources.environment.EnvironmentConfig
-
yagocd.resources.feed module¶
-
class
yagocd.resources.feed.
FeedManager
(session, pipeline_name=None, pipeline_counter=None, stage_name=None, stage_counter=None)[source]¶ Bases:
yagocd.resources.BaseManager
,yagocd.util.RequireParamMixin
The feed API allows users to view feed information.
Versionadded: 14.3.0. -
PIPELINES_RESOURCE_PATH
= '{base_api}/pipelines'¶
-
STAGES_RESOURCE_PATH
= '{base_api}/stages'¶
-
job_by_id
(*args, **kwargs)[source]¶ Gets XML representation of job.
Versionadded: 14.3.0. Parameters: job_id – id of job. Note: this is not a counter. Returns: a job object in XML format.
-
pipeline_by_id
(*args, **kwargs)[source]¶ Gets XML representation of pipeline.
Versionadded: 14.3.0. Parameters: pipeline_id – id of pipeline. Note: this is not a counter. Returns: a pipeline object in XML format.
-
pipelines
(*args, **kwargs)[source]¶ Lists all pipelines.
Versionadded: 14.3.0. Returns: an array of pipelines in XML format.
-
stage
(*args, **kwargs)[source]¶ Gets XML representation of stage.
Versionadded: 14.3.0.
Parameters: - pipeline_name – name of pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of stage.
- stage_counter – stage counter.
Returns: a stage object in XML format.
-
yagocd.resources.info module¶
-
class
yagocd.resources.info.
InfoManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
Class for getting general information about GoCD server. Mostly this class returns some system information about the server and not assumed to be used often.
Versionadded: 14.3.0. Right now this class just parses /about page, for more robust approach you can use yagocd.resources.version.VersionManager class.
-
ARTIFACT_FREE_SPACE_RE
= <_sre.SRE_Pattern object at 0x2692240>¶
-
DB_SCHEMA_VERSION_RE
= <_sre.SRE_Pattern object>¶
-
JVM_VERSION_RE
= <_sre.SRE_Pattern object>¶
-
OS_INFO_RE
= <_sre.SRE_Pattern object>¶
-
SERVER_VERSION_RE
= <_sre.SRE_Pattern object>¶
-
VERSION_NUMBER_RE
= <_sre.SRE_Pattern object>¶
-
artifact_free_space
¶
-
db_schema_version
¶
-
jvm_version
¶
-
os_info
¶
-
version
¶
-
yagocd.resources.job module¶
-
class
yagocd.resources.job.
JobInstance
(session, data, stage)[source]¶ Bases:
yagocd.resources.Base
Class representing specific job.
- Instances of this class can get different information about the job:
- get pipeline name/counter
- get stage name/counter
- list available artifacts
- list available properties
As this class is a container for multiple entities like artifacts, properties, so it doesn’t have magic methods __iter__ or __getitem__, as they would be ambiguous about their operands. This class gives access to those entities through the python properties, and each entity could implement those magic methods as needed.
-
artifacts
¶ Property for accessing artifact manager of the current job.
Returns: instance of yagocd.resources.artifact.ArtifactManager
Return type: yagocd.resources.artifact.ArtifactManager
-
pipeline_counter
¶ Get pipeline counter of current job instance.
Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get counter of the pipeline.
Returns: pipeline counter.
-
pipeline_name
¶ Get pipeline name of current job instance.
Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get name of the pipeline.
Returns: pipeline name.
-
properties
¶ Property for accessing property (doh!) manager of the current job.
Returns: instance of yagocd.resources.property.PropertyManager
Return type: yagocd.resources.property.PropertyManager
-
stage
¶
-
stage_counter
¶ Get stage counter of current job instance.
Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get counter of the stage.
Returns: stage counter.
-
stage_name
¶ Get stage name of current job instance.
Because instantiating job instance could be performed in different ways and those return different results, we have to check where from to get name of the stage.
Returns: stage name.
-
url
¶ Returns url for accessing job instance.
-
class
yagocd.resources.job.
JobManager
(session, pipeline_name=None, stage_name=None, job_name=None)[source]¶ Bases:
yagocd.resources.BaseManager
,yagocd.util.RequireParamMixin
The jobs API allows users to view job information.
Versionadded: 14.3.0. -
RESOURCE_PATH
= '{base_api}/jobs'¶
-
yagocd.resources.material module¶
-
class
yagocd.resources.material.
MaterialEntity
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
-
class
yagocd.resources.material.
MaterialManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The materials API allows users to query and notify materials in the Go configuration.
Versionadded: 14.3.0. -
list
(*args, **kwargs)[source]¶ Lists all available materials, these are materials that are present in the in
cruise-config.xml
.Versionadded: 14.3.0. Returns: An array of yagocd.resources.material.MaterialEntity
.Return type: list of yagocd.resources.material.MaterialEntity
-
modifications
(*args, **kwargs)[source]¶ Get modifications of specific material.
Versionadded: 14.3.0.
Parameters: - fingerprint – fingerprint of material.
- offset – number of modifications to be skipped.
Returns: A list of modification objects
yagocd.resources.material.ModificationEntity
.Return type: list of yagocd.resources.material.ModificationEntity
-
notify_git
(*args, **kwargs)[source]¶ APIs that notify Go Server when a commit has been made in Version Control and Go needs to trigger relevant pipelines.
Versionadded: 14.3.0. Warning: When using this feature, uncheck Poll for new changes or set autoUpdate flag in cruise configuration to false for the relevant material. Otherwise you will get: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8153/go/api/material/notify/git Parameters: url – The git repository url as defined in cruise-config.xml. Returns: A text confirmation.
-
notify_hg
(*args, **kwargs)[source]¶ APIs that notify Go Server when a commit has been made in Version Control and Go needs to trigger relevant pipelines.
Versionadded: 14.3.0. Warning: When using this feature, uncheck Poll for new changes or set autoUpdate flag in cruise configuration to false for the relevant material. Otherwise you will get: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8153/go/api/material/notify/hg Parameters: url – The git repository url as defined in cruise-config.xml. Returns: A text confirmation.
-
notify_svn
(*args, **kwargs)[source]¶ APIs that notify Go Server when a commit has been made in Version Control and Go needs to trigger relevant pipelines.
Versionadded: 14.3.0. Warning: When using this feature, uncheck Poll for new changes or set autoUpdate flag in cruise configuration to false for the relevant material. Otherwise you will get: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8153/go/api/material/notify/svn Parameters: uuid – The subversion repository UUID. Returns: A text confirmation.
-
-
class
yagocd.resources.material.
ModificationEntity
(session, data)[source]¶ Bases:
yagocd.resources.BaseNode
yagocd.resources.pipeline module¶
-
class
yagocd.resources.pipeline.
PipelineEntity
(session, data, group=None)[source]¶ Bases:
yagocd.resources.BaseNode
Class for the pipeline entity, which describes pipeline itself. Executing
history
will return pipeline instances.-
config
¶ Property for accessing pipeline configuration.
Return type: yagocd.resources.pipeline_config.PipelineConfigManager
-
full_history
()[source]¶ Method for accessing full history of specific pipeline.
It yields each instance and after one chunk is over moves to the next one. :return: an array of pipeline instances
yagocd.resources.pipeline.PipelineInstance
. :rtype: list of yagocd.resources.pipeline.PipelineInstance
-
get
(counter)[source]¶ Gets pipeline instance object.
Parameters: pipeline counter (counter) – Returns: A pipeline instance object yagocd.resources.pipeline.PipelineInstance
.Return type: yagocd.resources.pipeline.PipelineInstance
-
group
¶ Name of the group pipeline belongs to. :return: group name.
-
history
(offset=0)[source]¶ The pipeline history allows users to list pipeline instances.
Parameters: offset – number of pipeline instances to be skipped. Returns: an array of pipeline instances yagocd.resources.pipeline.PipelineInstance
.Return type: list of yagocd.resources.pipeline.PipelineInstance
-
last
()[source]¶ Get last pipeline instance.
Return type: yagocd.resources.pipeline.PipelineInstance
-
pause
(cause)[source]¶ Pause the current pipeline.
Parameters: cause – reason for pausing the pipeline.
-
release_lock
()[source]¶ Release a lock on a pipeline so that you can start up a new instance without having to wait for the earlier instance to finish.
Returns: a text confirmation.
-
schedule
(materials=None, variables=None, secure_variables=None)[source]¶ Scheduling allows user to trigger a specific pipeline.
Parameters: - materials – material revisions to use.
- variables – environment variables to set.
- secure_variables – secure environment variables to set.
Returns: a text confirmation.
-
schedule_with_instance
(materials=None, variables=None, secure_variables=None, backoff=0.5, max_tries=20)[source]¶ Schedule pipeline and return instance. Credits of implementation comes to gaqzi: https://github.com/gaqzi/py-gocd/blob/master/gocd/api/pipeline.py#L122
Warning: Replace this with whatever is the official way as soon as gocd#990 is fixed. https://github.com/gocd/gocd/issues/990
Parameters: - materials – material revisions to use.
- variables – environment variables to set.
- secure_variables – secure environment variables to set.
- backoff – time to wait before checking for new instance.
- max_tries – maximum tries to do.
Returns: possible triggered instance of pipeline.
Return type:
-
status
()[source]¶ The pipeline status allows users to check if the pipeline is paused, locked and schedulable.
Returns: JSON containing information about pipeline state, wrapped in EasyDict class.
-
url
¶ Returns url for accessing pipeline entity.
-
-
class
yagocd.resources.pipeline.
PipelineInstance
(session, data)[source]¶ Bases:
yagocd.resources.BaseNode
Pipeline instance represents concrete execution of specific pipeline.
-
config
¶ Property for accessing pipeline configuration.
Return type: yagocd.resources.pipeline_config.PipelineConfigManager
-
pipeline_url
¶ Returns url for accessing pipeline entity.
-
stage
(name)[source]¶ Method for searching specific stage by it’s name.
Parameters: name – name of the stage to search. Returns: found stage or None. Return type: yagocd.resources.stage.StageInstance
-
stages
()[source]¶ Method for getting stages from pipeline instance.
Returns: arrays of stages Return type: list of yagocd.resources.stage.StageInstance
-
url
¶ Returns url for accessing pipeline instance.
-
-
class
yagocd.resources.pipeline.
PipelineManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The pipelines API allows users to view pipeline information and operate on it.
Pipeline groups documentation.
Versionadded: 14.3.0. -
GROUPS_RESOURCE_PATH
= '{base_api}/config/pipeline_groups'¶
-
RESOURCE_PATH
= '{base_api}/pipelines/{name}'¶
-
VSM_RESOURCE_PATH
= '{base_api}/pipelines/value_stream_map/{name}'¶
-
find
(*args, **kwargs)[source]¶ Finds pipeline by it’s name.
Versionadded: 14.3.0. Parameters: name – name of required pipeline. Returns: if found - pipeline yagocd.resources.pipeline.PipelineEntity
, otherwiseNone
.Return type: yagocd.resources.pipeline.PipelineEntity
-
full_history
(*args, **kwargs)[source]¶ Method for accessing full history of specific pipeline.
Versionadded: 14.3.0. It yields each instance and after one chunk is over moves to the next one. :param name: name of the pipeline. :return: an array of pipeline instances
yagocd.resources.pipeline.PipelineInstance
. :rtype: list of yagocd.resources.pipeline.PipelineInstance
-
get
(*args, **kwargs)[source]¶ Gets pipeline instance object.
Versionadded: 14.3.0.
Parameters: - name – name of the pipeline.
- counter – pipeline counter.
Returns: A pipeline instance object
yagocd.resources.pipeline.PipelineInstance
.Return type:
-
history
(*args, **kwargs)[source]¶ The pipeline history allows users to list pipeline instances. Supports pagination using offset which tells the API how many instances to skip.
Versionadded: 14.3.0.
Parameters: - name – name of the pipeline.
- offset – number of pipeline instances to be skipped.
Returns: an array of pipeline instances
yagocd.resources.pipeline.PipelineInstance
.Return type: list of yagocd.resources.pipeline.PipelineInstance
-
last
(*args, **kwargs)[source]¶ Get last pipeline instance.
Versionadded: 14.3.0. Parameters: name – name of the pipeline. Return type: yagocd.resources.pipeline.PipelineInstance
-
list
(*args, **kwargs)[source]¶ List all available pipelines.
Versionadded: 14.3.0. This method uses
pipeline_groups
API method call to list available pipelines. It also links them together, so later it’s possible to refer to pipeline’s descendants. :return: array of pipelines :rtype: list of yagocd.resources.pipeline.PipelineEntity
-
pause
(*args, **kwargs)[source]¶ Pause the specified pipeline.
Versionadded: 14.3.0.
Parameters: - name – name of the pipeline.
- cause – reason for pausing the pipeline.
-
release_lock
(*args, **kwargs)[source]¶ Release a lock on a pipeline so that you can start up a new instance without having to wait for the earlier instance to finish.
Versionadded: 14.3.0. Parameters: name – name of the pipeline. Returns: a text confirmation.
-
schedule
(*args, **kwargs)[source]¶ Scheduling allows user to trigger a specific pipeline.
Versionadded: 14.3.0.
Parameters: - name – name of the pipeline.
- materials – material revisions to use.
- variables – environment variables to set.
- secure_variables – secure environment variables to set.
Returns: a text confirmation.
-
schedule_with_instance
(*args, **kwargs)[source]¶ Schedule pipeline and return instance. Credits of implementation comes to gaqzi: https://github.com/gaqzi/py-gocd/blob/master/gocd/api/pipeline.py#L122
Versionadded: 14.3.0.
Warning: Replace this with whatever is the official way as soon as gocd#990 is fixed. https://github.com/gocd/gocd/issues/990
Parameters: - name – name of the pipeline.
- materials – material revisions to use.
- variables – environment variables to set.
- secure_variables – secure environment variables to set.
- backoff – time to wait before checking for new instance.
- max_tries – maximum tries to do.
Returns: possible triggered instance of pipeline.
Return type:
-
status
(*args, **kwargs)[source]¶ The pipeline status allows users to check if the pipeline is paused, locked and schedulable.
Versionadded: 14.3.0. Parameters: name – name of the pipeline. Returns: JSON containing information about pipeline state, wrapped in EasyDict class.
-
yagocd.resources.pipeline_config module¶
-
class
yagocd.resources.pipeline_config.
PipelineConfig
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
-
class
yagocd.resources.pipeline_config.
PipelineConfigManager
(session, pipeline_name=None)[source]¶ Bases:
yagocd.resources.BaseManager
,yagocd.util.RequireParamMixin
The pipeline config API allows users with administrator role to manage pipeline config.
Versionadded: 15.3.0. -
ACCEPT_HEADER
= 'application/vnd.go.cd.v3+json'¶
-
RESOURCE_PATH
= '{base_api}/admin/pipelines'¶
-
VERSION_TO_ACCEPT_HEADER
= {'16.12.0': 'application/vnd.go.cd.v2+json', '16.6.0': 'application/vnd.go.cd.v1+json'}¶
-
create
(*args, **kwargs)[source]¶ Creates new pipeline.
Versionadded: 15.3.0. Parameters: config – configuration data. Returns: created pipeline config object. Return type: yagocd.resources.pipeline_config.PipelineConfig
-
delete
(*args, **kwargs)[source]¶ Deletes a pipeline.
Versionadded: 16.6.0. Parameters: pipeline_name – name of pipeline to delete Returns: A message confirmation if the pipeline was deleted. Return type: str
-
edit
(*args, **kwargs)[source]¶ Update pipeline config for specified pipeline name.
Versionadded: 15.3.0.
Parameters: - config – dictionary containing new configuration for a given pipeline.
- etag – etag value from current configuration resource.
- pipeline_name – name of the pipeline. Could be skipped if name was configured from constructor.
Returns: updated pipeline config object.
Return type:
-
get
(*args, **kwargs)[source]¶ Gets pipeline config for specified pipeline name.
Versionadded: 15.3.0. Parameters: pipeline_name – name of the pipeline. Could be skipped if name was configured from constructor. Returns: pipeline config object. Return type: yagocd.resources.pipeline_config.PipelineConfig
-
yagocd.resources.plugin_info module¶
-
class
yagocd.resources.plugin_info.
PluginInfo
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
-
class
yagocd.resources.plugin_info.
PluginInfoManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The plugin info API allows users with administrator role to fetch information about installed plugins.
Versionadded: 16.7.0. -
ACCEPT_HEADER
= 'application/vnd.go.cd.v2+json'¶
-
RESOURCE_PATH
= '{base_api}/admin/plugin_info'¶
-
VERSION_TO_ACCEPT_HEADER
= {'16.11.0': 'application/vnd.go.cd.v1+json'}¶
-
get
(*args, **kwargs)[source]¶ Gets plugin info for a specified plugin id.
Parameters: name – id or name of the plugin to get the info. Return type: yagocd.resources.plugin_info.PluginInfo
-
yagocd.resources.property module¶
-
class
yagocd.resources.property.
PropertyManager
(session, pipeline_name=None, pipeline_counter=None, stage_name=None, stage_counter=None, job_name=None)[source]¶ Bases:
yagocd.resources.BaseManager
,yagocd.util.RequireParamMixin
The properties API allows managing of job properties.
Versionadded: 14.3.0. This class implements dictionary like methods for similar use.
-
PATH_PARAMETERS
= ['pipeline_name', 'pipeline_counter', 'stage_name', 'stage_counter', 'job_name']¶
-
RESOURCE_PATH
= '{base_api}/properties/{pipeline_name}/{pipeline_counter}/{stage_name}/{stage_counter}/{job_name}'¶
-
create
(*args, **kwargs)[source]¶ Defines a property on a specific job instance.
Versionadded: 14.3.0.
Parameters: - name – name of property.
- value – value of property.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: an acknowledgement that the property was created.
-
get
(*args, **kwargs)[source]¶ Gets a property value by it’s name. :info: You can use keyword latest as a pipeline counter or a stage counter.
Versionadded: 14.3.0.
Parameters: - name – name of property to get.
- pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: value of requested property.
-
historical
(*args, **kwargs)[source]¶ Get historical properties. :info: limitPipeline and limitCount are optional parameters. The default value of limitPipeline is latest pipeline instance’s counter. The default value of limitCount is 100.
Versionadded: 14.3.0.
Parameters: - pipeline_name – name of the pipeline.
- stage_name – name of the stage.
- job_name – name of the job.
- limit_pipeline – pipeline limit for returned properties.
- limit_count – count limit for returned properties.
Returns: list of dictionaries as historical values.
-
list
(*args, **kwargs)[source]¶ Lists all job properties.
Versionadded: 14.3.0.
Parameters: - pipeline_name – name of the pipeline.
- pipeline_counter – pipeline counter.
- stage_name – name of the stage.
- stage_counter – stage counter.
- job_name – name of the job.
Returns: dictionary of properties.
Return type: dict[str, str]
-
yagocd.resources.scm module¶
-
class
yagocd.resources.scm.
SCMManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The pluggable SCM API allows users to view, create and update the SCM object.
Note: Please keep in mind that this API works with pluggable SCM materials, which means that you have to install specific SCM plugin to the GoCD server in order to work with it. Versionadded: 16.7.0. -
RESOURCE_PATH
= '{base_api}/admin/scms'¶
-
create
(*args, **kwargs)[source]¶ Create a global SCM object.
Parameters: config – new SCM configuration. Return type: yagocd.resources.scm.SCMMaterial
-
get
(*args, **kwargs)[source]¶ Gets pluggable scm material for a specified scm name.
Parameters: name – scm material name. Return type: yagocd.resources.scm.SCMMaterial
-
list
(*args, **kwargs)[source]¶ Lists all available pluggable scm materials, these are materials that are present in the in
cruise-config.xml
.Return type: list of yagocd.resources.scm.SCMMaterial
-
-
class
yagocd.resources.scm.
SCMMaterial
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
yagocd.resources.stage module¶
-
class
yagocd.resources.stage.
StageInstance
(session, data, pipeline)[source]¶ Bases:
yagocd.resources.Base
Class representing instance of specific stage.
-
job
(name)[source]¶ Method for searching specific job by it’s name.
Parameters: name – name of the job to search. Returns: found job or None. Return type: yagocd.resources.job.JobInstance
-
jobs
()[source]¶ Method for getting jobs from stage instance.
Returns: arrays of jobs. Return type: list of yagocd.resources.job.JobInstance
-
pipeline
¶
-
pipeline_counter
¶ Get pipeline counter of current stage instance.
Because instantiating stage instance could be performed in different ways and those return different results, we have to check where from to get counter of the pipeline.
Returns: pipeline counter.
-
pipeline_name
¶ Get pipeline name of current stage instance.
Because instantiating stage instance could be performed in different ways and those return different results, we have to check where from to get name of the pipeline.
Returns: pipeline name.
-
stage_counter
¶ Get stage counter of current instance.
This method is to be inline with others.
Returns: stage counter.
-
stage_name
¶ Get stage name of current instance.
This method is to be inline with others.
Returns: stage name.
-
url
¶ Returns url for accessing stage instance.
-
-
class
yagocd.resources.stage.
StageManager
(session, pipeline_name=None, pipeline_counter=None, stage_name=None, stage_counter=None)[source]¶ Bases:
yagocd.resources.BaseManager
,yagocd.util.RequireParamMixin
The stages API allows users to view stage information and operate on it.
Versionadded: 14.3.0. -
RESOURCE_PATH
= '{base_api}/stages/{pipeline_name}/{stage_name}'¶
-
RUN_RESOURCE_PATH
= '{base_api}/run/{pipeline_name}/{pipeline_counter}/{stage_name}'¶
-
cancel
(*args, **kwargs)[source]¶ Cancel an active stage of a specified stage.
Versionadded: 14.3.0.
Parameters: - pipeline_name – pipeline name.
- stage_name – stage name.
Returns: a text confirmation.
-
full_history
(*args, **kwargs)[source]¶ The stage history allows users to list stage instances of specified stage.
This method uses generator to get full stage history. :param pipeline_name: pipeline name. :param stage_name: stage name. :return: an array of stage instances
yagocd.resources.stage.StageInstance
. :rtype: list of yagocd.resources.stage.StageInstance
-
get
(*args, **kwargs)[source]¶ Gets stage instance object.
Versionadded: 15.1.0.
Parameters: - pipeline_name – pipeline name.
- stage_name – stage name.
- pipeline_counter – pipeline counter.
- stage_counter – stage counter.
Returns: a stage instance object
yagocd.resources.stage.StageInstance
.Return type:
-
history
(*args, **kwargs)[source]¶ The stage history allows users to list stage instances of specified stage. Supports pagination using offset which tells the API how many instances to skip.
Versionadded: 14.3.0.
Parameters: - pipeline_name – pipeline name.
- stage_name – stage name.
- offset – how many instances to skip.
Returns: an array of stage instances
yagocd.resources.stage.StageInstance
.Return type: list of yagocd.resources.stage.StageInstance
-
-
class
yagocd.resources.stage.
StageResult
[source]¶ Bases:
object
Enumeration of the Stage results.
These values are used to represent real status of a Stage. Looks like they’re calculated as aggregated value of each Job’s status.
Url: https://github.com/gocd/gocd/blob/master/domain/src/com/thoughtworks/go/domain/StageResult.java -
Cancelled
= 'Cancelled'¶
-
Failed
= 'Failed'¶
-
Passed
= 'Passed'¶
-
Unknown
= 'Unknown'¶
-
-
class
yagocd.resources.stage.
StageState
[source]¶ Bases:
object
Enumeration of the Stage statuses.
These statuses are used to determine general status of a given Stage from the status of it’s Jobs. The values from this enum are used in Jobs state parameter.
Url: https://github.com/gocd/gocd/blob/master/domain/src/com/thoughtworks/go/domain/StageState.java -
Building
= 'Building'¶
-
Cancelled
= 'Cancelled'¶
-
Failed
= 'Failed'¶
-
Failing
= 'Failing'¶
-
Passed
= 'Passed'¶
-
StateToResult
= {'Building': 'Unknown', 'Unknown': 'Unknown', 'Failing': 'Failed', 'Failed': 'Failed', 'Passed': 'Passed', 'Cancelled': 'Cancelled'}¶
-
Unknown
= 'Unknown'¶
-
yagocd.resources.template module¶
-
class
yagocd.resources.template.
TemplateConfig
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
-
class
yagocd.resources.template.
TemplateManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The template config API allows users with administrator role to manage template config.
Versionadded: 16.10.0. -
ACCEPT_HEADER
= 'application/vnd.go.cd.v3+json'¶
-
RESOURCE_PATH
= '{base_api}/admin/templates'¶
-
VERSION_TO_ACCEPT_HEADER
= {'16.10.0': 'application/vnd.go.cd.v1+json', '16.11.0': 'application/vnd.go.cd.v2+json'}¶
-
create
(*args, **kwargs)[source]¶ Creates a template config object.
Parameters: config – new template configuration. Return type: yagocd.resources.template.TemplateConfig
-
delete
(*args, **kwargs)[source]¶ Deletes a template from the config XML if it is not associated with any pipeline.
Parameters: name – name of template to delete Returns: A message confirmation if the template was deleted. Return type: str
-
get
(*args, **kwargs)[source]¶ Gets template config for specified template name.
Parameters: name – name of the template. Return type: yagocd.resources.template.TemplateConfig
-
list
(*args, **kwargs)[source]¶ Lists all available templates with the associated pipelines’ names.
Return type: list of yagocd.resources.template.TemplateConfig
-
yagocd.resources.user module¶
-
class
yagocd.resources.user.
UserEntity
(session, data, etag=None)[source]¶ Bases:
yagocd.resources.Base
The user object.
-
class
yagocd.resources.user.
UserManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The users API allows users with administrator role to manage users.
Versionadded: 15.2.0. -
CURRENT_USER_PATH
= '{base_api}/current_user'¶
-
RESOURCE_PATH
= '{base_api}/users'¶
-
create
(*args, **kwargs)[source]¶ Creates a user.
Versionadded: 15.3.0. TODO: can’t make this one work: returns 404 all the time.
Parameters: options – dictionary of parameters for creating a user. Returns: a user object yagocd.resources.user.UserEntity
.Return type: yagocd.resources.user.UserEntity
-
current
(*args, **kwargs)[source]¶ Gets the current user.
Versionadded: 17.5.0. Returns: a current user object yagocd.resources.user.UserEntity
.Return type: yagocd.resources.user.UserEntity
-
delete
(*args, **kwargs)[source]¶ Deletes a user.
Versionadded: 15.2.0. Parameters: login – login name. Returns: a message confirmation if the user was deleted.
-
get
(*args, **kwargs)[source]¶ Gets a user by its login name.
Versionadded: 15.2.0. Parameters: login – login name. Returns: a user object yagocd.resources.user.UserEntity
.Return type: yagocd.resources.user.UserEntity
-
list
(*args, **kwargs)[source]¶ Lists all available users.
Versionadded: 15.2.0. Returns: an array of user objects yagocd.resources.user.UserEntity
.Return type: list of yagocd.resources.user.UserEntity
-
update
(*args, **kwargs)[source]¶ Update some attributes of a user.
Versionadded: 15.2.0.
Parameters: - login – login name.
- options – dictionary of parameters for updating a user.
Returns: the updated user object
yagocd.resources.user.UserEntity
.Return type:
-
yagocd.resources.version module¶
-
class
yagocd.resources.version.
VersionManager
(session)[source]¶ Bases:
yagocd.resources.BaseManager
The Version API allows users to get the GoCD server version details.
Versionadded: 16.6.0.
Module contents¶
-
class
yagocd.resources.
BaseManager
(session)[source]¶ Bases:
object
-
ACCEPT_HEADER
= 'application/vnd.go.cd.v1+json'¶
-
VERSION_TO_ACCEPT_HEADER
= None¶
-
-
class
yagocd.resources.
BaseNode
(session, data)[source]¶ Bases:
yagocd.resources.Base
-
descendants
¶ Property for getting descendants (children) of current pipeline. It’s calculated by
yagocd.resources.pipeline.PipelineManager#tie_descendants()
method during listing of all pipelines.Returns: list of yagocd.resources.pipeline.PipelineEntity
.Return type: list of yagocd.resources.pipeline.PipelineEntity
-
get_descendants
(transitive=False)[source]¶ Property for getting descendants (children) of current pipeline. It’s calculated by
yagocd.resources.pipeline.PipelineManager#tie_descendants()
method during listing of all pipelines.Returns: list of yagocd.resources.pipeline.PipelineEntity
.Return type: list of yagocd.resources.pipeline.PipelineEntity
-
get_predecessors
(transitive=False)[source]¶ Property for getting predecessors (parents) of current pipeline. This property automatically populates from API call
Returns: list of yagocd.resources.pipeline.PipelineEntity
.Return type: list of yagocd.resources.pipeline.PipelineEntity
-
predecessors
¶ Property for getting predecessors (parents) of current pipeline. This property automatically populates from API call
Returns: list of yagocd.resources.pipeline.PipelineEntity
.Return type: list of yagocd.resources.pipeline.PipelineEntity
-