nexuscli.api package

Subpackages

Submodules

nexuscli.api.base_collection module

class nexuscli.api.base_collection.BaseCollection(nexus_http: nexuscli.nexus_http.NexusHttp = None)

Bases: object

A base collection class that contains a Nexus 3 client.

Parameters
  • nexus_http – the NexusHttp instance that will be used to perform requests against the Nexus

  • You must provide this at instantiation if you want to call any methods that (service.) –

  • connectivity to Nexus. (require) –

property list

Cached version of raw_list(). Use reset() to refresh.

raw_list() → List[dict]
reset() → None

Clears the cached collection and causes the next call to list() to reload the response from the Nexus server.

run_script(script_name: str, data: Union[str, dict] = '')

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.

script_dependencies() → List[str]

This method returns any scripts that the collection class depends on. These will be installed by the NexusClient instance, if not already present on the server.

nexuscli.api.base_model module

class nexuscli.api.base_model.BaseModel(nexus_http: Optional[nexuscli.nexus_http.NexusHttp] = None, **kwargs)

Bases: object

Base class for Nexus 3 server objects.

Parameters
  • nexus_http – the NexusHttp client instance that will be used to perform operations against

  • Nexus 3 service. You must provide this at instantiation if you plan on calling any (the) –

  • that require connectivity to Nexus. (methods) –

property configuration

The model representation as a transformed python dict suitable for converting to JSON and passing-through to the Nexus 3 API.

nexuscli.api.util module

nexuscli.api.util.script_for_version(script_name: str, server_version: semver.VersionInfo, versions: List[semver.VersionInfo]) → str

Determine if a certain nexus server version requires a different version of the given groovy script.

Parameters
  • script_name – original name of the script.

  • server_version – VersionInfo for the Nexus server.

  • versions – list of VersionInfo. Each element represents an existing groovy script that must be used with server_version or greater.

Returns

the version-specific name of script_name.

nexuscli.api.util.validate_response(response: requests.models.Response, accepted_codes: Union[int, List[int]], exc_class: Type[Exception] = <class 'nexuscli.exception.NexusClientAPIError'>) → None

Ensure that response.status_code is one of accepted_codes, otherwise raise exception exc_class using the response content as the error message.

nexuscli.api.util.with_min_version(min_version: str) → Callable[[F], F]

Verifies that the nexus_client instance has version greater or equal to min_version

nexuscli.api.validations module

nexuscli.api.validations.ensure_known(target: str, value: str, known: Iterable) → None

Validate whether the a target argument is known and supported. The target is only used to provide a friendlier message to the user. The given value is checked against known and supported.

Parameters
  • target – name of the target, as known to the end-user.

  • value – value of the target key.

  • known – known possible values for the target.

Raises

ValueError – if given value is not in known.

Module contents