pyjen.utils.datarequester module

Primitives for handling direct IO with the Jenkins REST API

class pyjen.utils.datarequester.DataRequester(jenkins_url, username, password)[source]

Bases: object

Abstraction layer encapsulate all IO requests for the Jenkins REST API

Parameters:
  • jenkins_url (str) – HTTP URL to use for all subsequent IO operations performed on this object.
  • username (str) – Jenkins user name to use for authentication. May be set to None for anonymous access.
  • password (str) – Password for the given Jenkins user, to use for authentication. May be set to None for anonymous access.
classmethod clear()[source]

Deletes all cached data so subsequent operations will reload from source

WARNING: Make sure to call flush() before clear() if there are potentially unwritten changes in the cache

clone(new_url=None)[source]

create a copy of this connection object

Parameters:new_url (str) – optional replacement URL associated with the cloned object credentials will be preserved in the clone
Returns:new DataRequester object, with settings cloned from this instance
Return type:DataRequester
config_xml[source]

Configuration file used to manage the Jenkins entity backed by this object

Return type:str
credentials[source]

Gets the authentication credentials used for all IO operations on this object

Returns:user name and password used for authenticated communication with Jenkins
Return type:tuple() of str
flush()[source]

Ensures that any non-synchronized changes cached by this object are uploaded to the remote Jenkins server

get_api_data(query_params=None)[source]

Convenience method that retrieves the Jenkins API specific data from the specified URL

Parameters:query_params (str) – optional set of query parameters to customize the returned data
Returns:The set of Jenkins attributes, converted to Python objects, associated with the given URL.
Return type:object
get_data(path=None)[source]

Convenience method to convert text data loaded from a Jenkins URL to Python data types

Parameters:path (str) – optional extension path to append to the root URL managed by this object when performing the get operation
Returns:The results of converting the text data loaded from the Jenkins URL into appropriate Python objects
Return type:object
get_headers(path=None)[source]

gets the HTTP header attributes from a Jenkins URL

Parameters:path (str) – optional extension path to append to the root URL managed by this object when performing the get operation
Returns:dictionary of HTTP header attributes with their associated values
Return type:dict
get_text(path=None)[source]

gets the raw text data from a Jenkins URL

Parameters:path (str) – optional extension path to append to the root URL managed by this object when performing the get operation
Returns:the text loaded from this objects’ URL
Return type:str
is_dirty[source]

Checks to see if there are any unsynchronized changes pending on this object

Returns:True if there are changes cached in this instance that have not yet been flushed to the remote Jenkins server, False otherwise
Return type:bool
post(path=None, args=None)[source]

sends data to or triggers an operation via a Jenkins URL

Parameters:
  • path (str) – optional extension path to append to the root URL managed by this object when performing the post operation
  • args (dict) –

    optional set of data arguments to be sent with the post operation supported keys are as follows:

    • ‘headers’ - dictionary of HTTP header properties and their associated values
    • ‘data’ - dictionary of assorted / misc data properties and their values
url[source]

Gets the URL used by all IO operations on this object

Returns:the URL used by all IO operations on this object
Return type:str