Request

This module defines the Request class for creating and handling requests to the Ankaios system.

Classes

  • Request:

    Represents a request to the Ankaios system and provides methods to get and set the state of the system.

Enums

  • RequestType:

    Enumeration for the different types of requests. It includes UPDATE_STATE and GET_STATE.

Usage

  • Create a Request for updating the state:
    request = Request(RequestType.UPDATE_STATE)
    request.set_complete_state(complete_state)
    
  • Create a Request for getting the state:
    request = Request(RequestType.GET_STATE)
    
  • Get the request ID:
    request_id = request.get_id()
    
  • Add a mask to the request:
    request.add_mask("desiredState.workloads")
    

Request Class

class ankaios_sdk._components.request.Request(request_type)[source]

Bases: object

Represents a request to the Ankaios system.

__init__(request_type)[source]

Initializes a Request instance with the given request type.

Parameters:

request_type (RequestType) – The type of the request.

Raises:

RequestException – If the request type is invalid.

__str__()[source]

Returns the string representation of the request.

Returns:

The string representation of the request.

Return type:

str

get_id()[source]

Gets the request ID.

Returns:

The request ID.

Return type:

str

set_complete_state(complete_state)[source]

Sets the complete state for the request.

Parameters:

complete_state (CompleteState) – The complete state to set for the request.

Raises:

RequestException – If the request type is not UPDATE_STATE.

Return type:

None

add_mask(mask)[source]

Sets the update mask for the request.

Parameters:

mask (str) – The mask to set for the request.

Return type:

None

set_masks(masks)[source]

Sets the update masks for the request.

Parameters:

masks (list) – The masks to set for the request.

Return type:

None

RequestType Enum

class ankaios_sdk._components.request.RequestType(value)[source]

Bases: Enum

Enumeration for the different types of requests.

UPDATE_STATE = 1

Request for updating the state.

Type:

(int)

GET_STATE = 2

Request for getting the state.

Type:

(int)

__str__()[source]

Return the string representation of the enum value.

Returns:

The enum value as a string.

Return type:

str