nexuscli.api.script package

Submodules

nexuscli.api.script.model module

class nexuscli.api.script.model.Script

Bases: object

A Class representing a Nexus 3 script.

class nexuscli.api.script.model.ScriptCollection(client=None)

Bases: object

A class to manage Nexus 3 scripts.

Parameters

client (nexuscli.nexus_client.NexusClient) – the client instance that will be used to perform operations against the Nexus 3 service. You must provide this at instantiation or set it before calling any methods that require connectivity to Nexus.

client

as per client argument of ScriptCollection.

Type

nexuscli.nexus_client.NexusClient

create(script_name, script_content, script_type='groovy')

Create the given script in the Nexus 3 service.

Parameters
  • script_name (str) – name of script to be created.

  • script_content (str) – script code.

  • script_type (str) – type of script to be created.

Raises

exception.NexusClientAPIError – if the script creation isn’t successful; i.e.: any HTTP code other than 204.

create_if_missing(name, content=None, script_type='groovy')

Creates a script in the Nexus 3 service IFF a script with the same name doesn’t exist. Equivalent to checking if the script exists with get() and, if not, creating it with create().

Parameters
  • name (str) – name of script to be created.

  • content (Union[str,NoneType]) – script code. If not given, the method will use nexuscli.nexus_util.groovy_script() to read the script code from a local file.

  • script_type (str) – type of script to be created.

Raises

exception.NexusClientAPIError – if the script creation isn’t successful; i.e.: any HTTP code other than 204.

delete(script_name)

Deletes a script from the Nexus 3 repository.

Parameters

script_name – name of script to be deleted.

Raises

exception.NexusClientAPIError – if the Nexus service fails to delete the script; i.e.: any HTTP code other than 204.

exists(name)

Check if a script exists.

Parameters

name – of script to verify existence.

Returns

True if it exists, false otherwise

Return type

bool

Raises

exception.NexusClientAPIError – if the response from the Nexus service isn’t recognised; i.e.: any HTTP code other than 200, 404.

get(name)

Get a Nexus 3 script by name.

Parameters

name – of script to be retrieved.

Returns

the script or None, if not found

Return type

dict, None

Raises

exception.NexusClientAPIError – if the response from the Nexus service isn’t recognised; i.e.: any HTTP code other than 200, 404.

list()

List of all script names on the Nexus 3 service.

Returns

a list of names

Return type

list

Raises

exception.NexusClientAPIError – if the script names cannot be retrieved; i.e.: any HTTP code other than 200.

run(script_name, data='')

Runs an existing script on the Nexus 3 service.

Parameters
  • script_name – name of script to be run.

  • data – parameters to be passed to the script, via HTTP POST. If the script being run requires a certain format or encoding, you need to prepare it yourself. Typically this is json.dumps(data).

Returns

the content returned by the script, if any.

Return type

str, dict

Raises

exception.NexusClientAPIError – if the Nexus service fails to run the script; i.e.: any HTTP code other than 200.

Module contents