runzero.client.client#

client provides the runZero platform Client which must be provided to all objects which interact with the runZero API.

Module Contents#

Classes#

Client

The authenticated connection to your runZero service destination.

class runzero.client.client.Client(account_key: str | None = None, org_key: str | None = None, server_url: str | None = None, timeout_seconds: int | None = None, validate_certificate: bool | None = None)[source]#

The authenticated connection to your runZero service destination.

A client must be built and provided to objects which interact with the runZero API. It is responsible for authentication and communication, and instantiation should be your first step in doing just about anything in this SDK.

Parameters:
  • account_key (Optional[str]) – Optional account key, sometimes known as client key, which is a high-privilege key which grants the holder the rights of an org_key across all organizations in the account, as well as additional administrative actions. Account keys are 30-character hexadecimal strings that with ‘CT’. Set this value, use an org_key, or use Oauth by calling register_api_client(). OAuth should be preferred.

  • org_key (Optional[str]) – Optional organization key which grants the holder rights to operations confined to a specific runZero organization. Org keys are 30-character hexadecimal strings that with ‘OT’. Set this value, use an account_key, or use Oauth by calling register_api_client(). OAuth should be preferred.

  • server_url (str) – Optional URL to the server hosting the API. Self-hosted API server targets must provide the server url in string form, e.g. ‘https://runzero.local:8443’ If not provided, the default hosted infrastructure URL ‘https://console.runzero.com’ is used.

  • validate_certificate (bool) – Optional bool to change whether Client checks the validity of the API server’s certificate before proceeding. We recommend not setting this to false unless you are doing local development or testing. Ignoring certificate validation errors can result in credential theft or other bad outcomes.

Constructor method

property last_rate_limit_information: runzero.types.RateLimitInformation | None#

The last rate limit information retrieved from the server.

Returns:

Rate limit information when provided.

Return type:

Optional[runzero.types.RateLimitInformation]

property oauth_active: bool#
Returns true if the OAuth is in use.

This happens when register_api_client was called successfully

Returns:

bool: indicating whether the oauth token is expired. If there is no oauth used with the client, value is always false.

Return type:

bool

property oauth_token_is_expired: bool#

Returns true if the oauth token is no longer valid.

Note that the token is automatically refreshed for you when possible. This value doesn’t need to be checked and manually refreshed in most cases.

Returns:

bool: indicating whether the oauth token is expired. If OAuth is not in-use with the client, value is always false.

Return type:

bool

property timeout: int#

The set request timeout value in seconds

Returns:

timeout in seconds

Return type:

int

property url: str#

The url of the server

Returns:

str: The URL of the runZero server

Return type:

str

property validate_cert: bool#

Boolean indicating whether the https cert must valid before proceeding.

Returns:

true if certficate information is validated, false if not

Return type:

bool

execute(method: str, endpoint: str, params: Any | None = None, data: pydantic.BaseModel | None = None, files: Any | None = None, multipart: bool | None = None) runzero.client._http.io.Response[source]#

Executes the request

Parameters:
  • method (str) – The REST verb to use

  • endpoint (str) – The path to execute against

  • params (Optional[Any]) – URL query parameters

  • data (Optional[pydantic.BaseModel]) – The data to send in form body (POST, PATCH, PUT)

  • files (Optional[Any]) – For multipart form data or file uploads. Format varies.

  • multipart (Optional[bool]) – True if using a multipart form data (combination file[s] and form data)

Returns:

The result of the execution as class:.`Response`

Raises:

ValidationError, ConnTimeoutError, ConnError, CommunicationError

Return type:

runzero.client._http.io.Response

oauth_login(client_id: str, client_secret: str) None[source]#

Registers the runZero SDK client using OAuth credentials, and enables the Client to use OAuth.

To obtain a client ID and client secret, see the API Clients area of the product. Generation of these values is restricted to account administrators.

Parameters:
  • client_id (str) – The client ID for the runZero registered API client

  • client_secret (str) – The client secret for the runZero registered API client

Raises:

AuthError: Exception for invalid OAuth configurations