Skip to content

Table of Contents

api

Api Objects

class Api()

The class includes all necessary methods to make API calls to the Grafana API endpoints

Arguments:

  • grafana_api_model APIModel - Inject a Grafana API model object that includes all necessary values and information

Attributes:

  • grafana_api_model APIModel - This is where we store the grafana_api_model

call_the_api

def call_the_api(api_call: str,
                 method: RequestsMethods = RequestsMethods.GET,
                 json_complete: str = None,
                 org_id_header: int = None,
                 disable_provenance_header: bool = False,
                 response_status_code: bool = False) -> any

The method execute a defined API call against the Grafana endpoints

Arguments:

  • api_call str - Specify the API call endpoint
  • method RequestsMethods - Specify the used method (default GET)
  • json_complete str - Specify the inserted JSON as string
  • org_id_header int - Specify the optional organization id as header for the corresponding API call
  • disable_provenance_header bool - Specify the optional disable provenance as header for the corresponding API call (default False)
  • response_status_code bool - Specify if the response should include the original status code (default False)

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

  • api_call any - Returns the value of the api call

prepare_api_string

@staticmethod
def prepare_api_string(query_string: str) -> str

The method includes a functionality to prepare the api string for the queries

Arguments:

  • query_string str - Specify the corresponding query string

Returns:

  • query_string str - Returns the adjusted query string

create_the_http_api_client

def create_the_http_api_client(
        headers: dict = None) -> Union[httpx.Client, httpx.AsyncClient]

The method includes a functionality to create the corresponding HTTP client

Arguments:

  • headers dict - Specify the optional inserted headers (Default None)

Returns:

  • client Union[httpx.Client, httpx.AsyncClient] - Returns the corresponding client