Variable

class perses_api.variable.GlobalVariable[source]

Bases: VariableBase

The class includes all necessary methods to access the Perses global variables API

Parameters:

perses_api_model (APIModel) – Inject a Perses API model object that includes all necessary values and information

api

This is where we store the api

Type:

Api

class perses_api.variable.ProjectVariable[source]

Bases: VariableBase

The class includes all necessary methods to access the Perses project-scoped variables API

Parameters:
  • perses_api_model (APIModel) – Inject a Perses API model object that includes all necessary values and information

  • project_name (str) – Specify the name of the project to scope variable operations to

api

This is where we store the api

Type:

Api

project_name

This is where we store the project_name

Type:

str

__init__(perses_api_model: APIModel, project_name: str)[source]
class perses_api.variable.VariableBase[source]

Bases: ResourceBase

The class includes all necessary base methods to access the Perses variables API

Parameters:

perses_api_model (APIModel) – Inject a Perses API model object that includes all necessary values and information

api

This is where we store the api

Type:

Api

create_variable(variable) dict[source]

The method includes a functionality to create a new variable

Parameters:

variable (Variable | GlobalVariable) – Specify the variable resource to create

Raises:

Exception – Unspecified error by executing the API call

Returns:

The created variable dict

Return type:

dict

delete_variable(name: str) None[source]

The method includes a functionality to delete a variable by name

Parameters:

name (str) – Specify the name of the variable to delete

Raises:

ValueError – Missed specifying a necessary value

get_variable(name: str) dict[source]

The method includes a functionality to retrieve a single variable by name

Parameters:

name (str) – Specify the name of the variable to retrieve

Raises:
  • ValueError – Missed specifying a necessary value

  • Exception – Unspecified error by executing the API call

Returns:

The variable dict

Return type:

dict

get_variables(name: str = None) list[source]

The method includes a functionality to retrieve all variables

Parameters:

name (str) – Specify a name to filter the results (default None)

Raises:

Exception – Unspecified error by executing the API call

Returns:

A list of variable dicts

Return type:

list

update_variable(name: str, variable) dict[source]

The method includes a functionality to update an existing variable by name

Parameters:
  • name (str) – Specify the name of the variable to update

  • variable (Variable | GlobalVariable) – Specify the updated variable resource

Raises:
  • ValueError – Missed specifying a necessary value

  • Exception – Unspecified error by executing the API call

Returns:

The updated variable dict

Return type:

dict