AppDPyAPI package

Module contents

Unofficial Python SDK for the AppDynamics API.

Submodules

AppDPyAPI.controller module

class AppDPyAPI.controller.AppDController(controller_base_url: str, client_id: str, client_secret: str)

Bases: object

AppDynamics controller, authorized using OAuth. Requires an API client.

get(uri: str, **kwargs: dict[str, str]) Response

Wrapper for requests.get.

Automatically adds auth’s AppDOAuthToken as Bearer token in authorization header in a thread-safe manner, unless a different authorization header is passed in **kwargs.

To request JSON from the API (not supported on all endpoints, see docs), add the output=JSON parameter to **kwargs.

Example: get(uri, params={“output”: “JSON”}).

Parameters:
  • uri (str) – The URI to GET.

  • **kwargs – See requests.get.

Returns:

The API response.

Return type:

requests.Response

get_application(application_name: str) dict[str, str]

Request an application from the controller by application name, formatted in JSON.

Parameters:

application_name (str) – The application name.

Returns:

The parsed API response.

Return type:

dict[str, str]

get_applications() list[dict[str, str]]

Request all applications from the controller, formatted in JSON.

Returns:

The parsed API response.

Return type:

list[dict[str, str]]

get_auto_transaction_detection_rules(application_id: int) str

Request all automatic transaction detection rules for an application by application ID, formatted in XML.

Parameters:

application_id (int) – The application ID.

Returns:

The XML string of transaction detection rules.

Return type:

str

get_business_transactions(application_name: str) list[dict[str, str]]

Request all business transactions for an application by application name, formatted in JSON.

Parameters:

application_name (str) – The application name.

Returns:

The parsed API response.

Return type:

list[dict[str, str]]

get_custom_transaction_detection_rules(application_id: int) str

Request all custom transaction detection rules for an application by application ID, formatted in XML.

Parameters:

application_id (int) – The application ID.

Returns:

The XML string of transaction detection rules.

Return type:

str

get_license_allocation_by_license_key(accountId: int, license_key: str)

Requires Infrastructure-Based Licensing (IBL). Like get_license_allocations, but additionally filtered by license key.

get_license_allocation_by_name(accountId: int, allocation_name: str)

Requires Infrastructure-Based Licensing (IBL). Like get_license_allocations, but additionally filtered by allocation name.

get_license_allocations(accountId: int)

Requires Infrastructure-Based Licensing (IBL). Retrieve all license allocations for account with ID accountId.

Parameters:

accountId (int) – The account ID.

Returns:

The parsed API response.

Return type:

list[dict[str, str | int | list[str]]]

get_license_allocations_by_tag(accountId: int, tag: str)

Requires Infrastructure-Based Licensing (IBL). Like get_license_allocations, but additionally filtered by tag assocatied with allocations.

get_license_rules()

Requires Agent-Based Licensing (ABL). Get license rules.

post(uri: str, **kwargs: dict[str, str]) Response

Wrapper for requests.post.

Automatically adds auth’s AppDOAuthToken as Bearer token in authorization header in a thread-safe manner, unless a different authorization header is passed in **kwargs.

To request JSON from the API (not supported on all endpoints, see docs), add the output=JSON parameter to **kwargs.

Example: post(uri, params={“output”: “JSON”}).

Parameters:
  • uri (str) – The URI to POST.

  • **kwargs – See requests.post.

Returns:

The API response.

Return type:

requests.Response

request(method: str, uri: str, **kwargs: dict[str, str]) Response

Wrapper for requests.request.

Automatically adds auth’s AppDOAuthToken as Bearer token in authorization header in a thread-safe manner, unless a different authorization header is passed in **kwargs.

To request JSON from the API (not supported on all endpoints, see docs), add the output=JSON parameter to **kwargs.

Example: request(“GET”, uri, params={“output”: “JSON”}).

Parameters:
  • method (str) – “GET”, “OPTIONS”, “HEAD”, “POST”, “PUT”, “PATCH”, or “DELETE”

  • uri (str) – The URI to request.

  • **kwargs – See requests.request.

Returns:

The API response.

Return type:

requests.Response

AppDPyAPI.oauth module

class AppDPyAPI.oauth.AppDOAuth(controller_base_url: str, client_id: str, client_secret: str)

Bases: object

AppDynamics controller authorization using OAuth. Requires an API client.

class AppDOauthToken(token: str | None = None, expiry: int | None = None, _lock: ~_thread.allocate_lock = <unlocked _thread.lock object>)

Bases: object

Allows token to be used like strings, but with lock and unlock methods and expiry timestamp.

token

The Bearer token.

Type:

str | None

expiry

The token’s expiry date as a UNIX timestamp.

Type:

int | None

lock()

Acquire the token lock. Should be called before using the token.

unlock()

Release the previously acquired token lock. Should be called after using the token.

get_token() AppDOauthToken

Get access token.

Returns:

Acccess token.

Return type:

AppDOAuthToken

lock_token()

Wrapper for self._token.lock().

Acquire the token lock. Should be called before using the token.

stop_refreshing_token() None

Stop refreshing the access token.

unlock_token()

Wrapper for self._token.unlock().

Release the previously acquired token lock. Should be called after using the token.

exception AppDPyAPI.oauth.AppDOAuthAuthorizationFailed

Bases: AppDOAuthException

class AppDPyAPI.oauth.AppDOAuthConfig(CONTROLLER_BASE_URL: str, CLIENT_ID: str, CLIENT_SECRET: str, keep_refreshing_token: bool = True, TOKEN_KEY: str = 'access_token', EXPIRY_KEY: str = 'expires_in', OAUTH_ENDPOINT: str = '/controller/api/oauth/access_token')

Bases: object

exception AppDPyAPI.oauth.AppDOAuthException

Bases: AppDException

exception AppDPyAPI.oauth.AppDOAuthExpiryKeyNotFound

Bases: AppDOAuthException

exception AppDPyAPI.oauth.AppDOAuthTokenKeyNotFound

Bases: AppDOAuthException