loadero_python.resources.group module
Loadero group resource.
- Group resource is seperated into three parts
GroupParams class describes groups attributes
GroupAPI class groups all API operations related to groups.
Group class combined GroupParams and GroupAPI
Single group object coresponds to single group in Loadero.
- class loadero_python.resources.group.Group(group_id: int | None = None, test_id: int | None = None, params: GroupParams | None = None)[source]
Bases:
LoaderoResourceGroup class allows to perform CRUD operations on a single Loadero group resource.
APIClient must be previously initialized with a valid Loadero access token.
The target Loadero group resource is determined by GroupParams.
- create() Group[source]
Creates new group with given data.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
test_id
count
name
- Raises:
ValueError: If resource params do not sufficiently identify parent resource or resource params required attributes are None.
APIException: If API call fails.
- Returns:
Group: Created group resource.
- delete() None[source]
Deletes and existing group.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
group_id
test_id
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- duplicate(name: str) Group[source]
Duplicates and existing group.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
group_id
test_id
- Args:
name (str): New name for the duplicate group.
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
Group: Duplicate instance of group.
- participants(query_params: QueryParams | None = None) tuple[list[Participant], PaginationParams, dict[any, any]][source]
Read all participants in group.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
group_id
test_id
- Args:
query_params (QueryParams, optional): Describes query parameters
- Raises:
ValueError: Test.params.test_id must be a valid int.
APIException: If API call fails.
- Returns:
list[Participant]: List of participants in group.
- read() Group[source]
Reads information about an existing group.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
test_id
group_id
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
Group: Read group resource.
- update() Group[source]
Updates group with given parameters.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
group_id
test_id
count
name
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
Group: Updated group resource.
- class loadero_python.resources.group.GroupAPI[source]
Bases:
objectGroupAPI defines Loadero API operations for group resources.
- static create(params: GroupParams) GroupParams[source]
Create a new group resource.
- Args:
params (GroupParams): Describes the group resource to be created.
- Raises:
ValueError: If resource params do not sufficiently identify parent resource or resource params required attributes are None.
APIException: If API call fails.
- Returns:
GroupParams: Created group resource.
- static delete(params: GroupParams) None[source]
Delete an existing group resource.
- Args:
params (GroupParams): Describes the group resource to delete.
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- static duplicate(params: GroupParams, name: str) GroupParams[source]
Duplicate an existing group resource.
- Args:
params (GroupParams): Identified the group resource to duplicate.
name (str): Name of the duplicate group.
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
GroupParams: Duplicate group resource.
- static read(params: GroupParams) GroupParams[source]
Read an existing group resource.
- Args:
params (GroupParams): Describes the group resource to read.
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
GroupParams: Read group resource.
- static read_all(test_id: int, query_params: QueryParams | None = None) PagedResponse[source]
Read all group resources.
- Args:
test_id (int): Parent test resource id.
query_params (QueryParams, optional): Describes query parameters.
- Returns:
PagedResponse: Paged response of group resources.
- static route(test_id: int, group_id: int | None = None) str[source]
Build group resource url route.
- Args:
test_id (int): Test resource id.
group_id (int, optional): Group resource id. Defaults to None. If omitted the route will point to all group resources.
- Returns:
str: Route to group resource/s.
- static update(params: GroupParams) GroupParams[source]
Update an existing group resource.
- Args:
params (GroupParams): Describes the group resource to update.
- Raises:
ValueError: If resource params do not sufficiently identify resource or resource params required attributes are None.
APIException: If API call fails.
- Returns:
GroupParams: Updated group resource.
- class loadero_python.resources.group.GroupFilterKey(value)[source]
Bases:
FilterKeyGroupFilterKey is an enum of all filter keys for group read all API operation.
- COUNT_FROM = 'filter_count_from'
- COUNT_TO = 'filter_count_to'
- NAME = 'filter_name'
- class loadero_python.resources.group.GroupParams(group_id: int | None = None, test_id: int | None = None, name: str | None = None, count: int | None = None)[source]
Bases:
LoaderoResourceParamsGroupParams represents Loadero group resource attributes.
GroupParams has a builder pattern for group resources writeable attributes.
- property created: datetime
Time when group was created.
- Returns:
datetime: Time when group was created.
- in_test(tid: int) GroupParams[source]
Set parent test id.
- Args:
tid (int): Test id.
- Returns:
GroupParams: Group params with set parent test id.
- property participant_count: int
Participant count in group.
- Returns:
int: Participant count in group.
- property total_cu_count: int
Total compute unit count in group.
- Returns:
int: Total compute unit count in group.
- property updated: datetime
Time when group was last updated.
- Returns:
datetime: Time when group was last updated.
- with_count(count: int) GroupParams[source]
Set group count.
- Args:
count (int): Group count.
- Returns:
GroupParams: Group params with set group count.
- with_id(group_id: int) GroupParams[source]
Set group id.
- Args:
group_id (int): Group id.
- Returns:
GroupParams: Group params with set group id.
- with_name(name: str) GroupParams[source]
Set group name.
- Args:
name (str): Group name.
- Returns:
GroupParams: Group params with set group name.