loadero_python.resources.participant module

Loadero participant resource.

Participant resources is seperated into three parts

ParticipantParams class describes participant attributes

ParticipantAPI groups all API operations with participant resource.

Participant class combines ParticipantParams and ParticipantAPI.

Single Participant object coresponds to single participant in Loadero.

class loadero_python.resources.participant.Participant(participant_id: int | None = None, test_id: int | None = None, params: ParticipantParams | None = None)[source]

Bases: LoaderoResource

Participant class allows to perform CRUD operations on Loadero participant resources.

APIClient must be previously initialized with a valid Loadero access token.

The target Loadero participant resource is determined by ParticipantParams.

create() Participant[source]

Creates new participant with given data.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • name

  • count

  • compute_unit

  • record_audio

  • audio_feed

  • browser

  • location

  • network

  • video_feed

Raises:

ValueError: If resource params do not sufficiently identify parent resource or resource params required attributes are None.

APIException: If API call fails.

Returns:

Participant: Created participant resource.

delete() None[source]

Deletes and existing participant.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • participant_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

duplicate(name: str) Participant[source]

Duplicates and existing participant.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • participant_id

Args:

name (str): New name for the duplicate participant.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Participant: Duplicate instance of participant.

read() Participant[source]

Reads information about an existing participant.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • participant_id

  • test_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Participant: Read participant resource.

update() Participant[source]

Updates particpant with given parameters.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • participant_id

  • test_id

  • name

  • count

  • compute_unit

  • record_audio

  • audio_feed

  • browser

  • location

  • network

  • video_feed

Raises:

ValueError: If resource params do not sufficiently identify resource or resource params required attributes are None.

APIException: If API call fails.

Returns:

Participant: Updated participant resource.

class loadero_python.resources.participant.ParticipantAPI[source]

Bases: object

ParticipantAPI defines Loadero API operations for participant resources.

static create(params: ParticipantParams) ParticipantParams[source]

Create a new participant resource.

Args:

params (ParticipantParams): Describes the participant 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:

ParticipantParams: Created participant resource.

static delete(params: ParticipantParams) None[source]

Delete an existing participant resource.

Args:

params (ParticipantParams): Describes the participant resource to delete.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

static duplicate(params: ParticipantParams, name: str) ParticipantParams[source]

Duplicate an existing participant resource.

Args:

params (ParticipantParams): Describes the participant resource to duplicate and the name of duplicate participant resource.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

ParticipantParams: Duplicate participant resource.

static read(params: ParticipantParams) ParticipantParams[source]

Read an existing participant resource.

Args:

params (ParticipantParams): Describes the participant resource to read.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

ParticipantParams: Read participant resource.

static read_all(test_id: int, group_id: int | None = None, query_params: QueryParams | None = None) PagedResponse[source]

Real all participant resources.

Args:

test_id (int): Parent test resource id.

group_id (int, optional): Parent group resource id. Defaults to None. If omitted all participants in parent test will be read.

query_params (QueryParams, optional): Describes query parameters.

Returns:

PagedResponse: Paged response of participant resources.

static route(test_id: int, participant_id: int | None = None, group_id: int | None = None) str[source]

Build participant resource url route.

Args:

test_id (int): Test resource id.

participant_id (int, optional): Participant resource id. Defaults to None. If omitted the route will point to all participant resources.

Returns:

str: Route to participant resource/s.

static update(params: ParticipantParams) ParticipantParams[source]

Update an existing participant resource.

Args:

params (ParticipantParams): Describes the participant 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:

ParticipantParams: Updated participant resource.

class loadero_python.resources.participant.ParticipantFilterKey(value)[source]

Bases: FilterKey

ParticipantFilterKey is an enum of all filter keys for participant read all API operation.

AUDIO_FEED = 'filter_audio_feed'
BROWSER = 'filter_browser'
COMPUTE_UNIT = 'filter_compute_unit'
COUNT_FROM = 'filter_count_from'
COUNT_TO = 'filter_count_to'
HAS_GROUP = 'filter_has_group'
LOCATION = 'filter_location'
NAME = 'filter_name'
NETWORK = 'filter_network'
RECORD_AUDIO = 'filter_record_audio'
VIDEO_FEED = 'filter_video_feed'
class loadero_python.resources.participant.ParticipantParams(participant_id: int | None = None, test_id: int | None = None, group_id: int | None = None, name: str | None = None, count: int | None = None, compute_unit: ComputeUnit | None = None, record_audio: bool | None = None, audio_feed: AudioFeed | None = None, browser: Browser | None = None, location: Location | None = None, network: Network | None = None, video_feed: VideoFeed | None = None)[source]

Bases: LoaderoResourceParams

ParticipantParams describes single Loadero participant resources attributes.

ParticipantParams has a builder pattern for Participant resource writeable attributes.

property created: datetime

Time when participant was created.

Returns:

datetime: Time when participant was created.

in_group(group_id: int) ParticipantParams[source]

Set participant parent group id.

Args:

group_id (int): Group id.

Returns:

ParticipantParams: Participant params with set parent group id.s

in_test(test_id: int) ParticipantParams[source]

Set parent test id.

Args:

test_id (int): Test id.

Returns:

ParticipantParams: Participant params with parent test id set.

property updated: datetime

Time when particpant was last updated.

Returns:

datetime: Time when participant was last updated.

with_audio_feed(audio_feed: AudioFeed) ParticipantParams[source]

Set participant audio feed.

Args:

audio_feed (AudioFeed): Participant audio feed.

Returns:

ParticipantParams: Participant params with set audio feed.

with_browser(browser: Browser) ParticipantParams[source]

Set participant browser.

Args:

browser (Browser): Browser.

Returns:

ParticipantParams: Participant params with set browser.

with_compute_unit(compute_unit: ComputeUnit) ParticipantParams[source]

Set participant compute unit.

Args:

compute_unit (ComputeUnit): Compute unit.

Returns:

ParticipantParams: Participant params with set compute unit.

with_count(count: int) ParticipantParams[source]

Set participant count.

Args:

count (int): Participant count.

Returns:

ParticipantParams: Participant params with participant count set.

with_id(participant_id: int) ParticipantParams[source]

Set participant id.

Args:

participant_id (int): Participant id.

Returns:

ParticipantParams: Participant params with participant id set.

with_location(location: Location) ParticipantParams[source]

Set participant location.

Args:

location (Location): Location.

Returns:

ParticipantParams: Participant params with set location.

with_name(name: str) ParticipantParams[source]

Set participant name.

Args:

name (str): Participant name.

Returns:

ParticipantParams: Participant params with participant name set.

with_network(network: Network) ParticipantParams[source]

Set participant network.

Args:

network (Network): Network.

Returns:

ParticipantParams: Participant params with set network.

with_record_audio(record_audio: bool) ParticipantParams[source]

Set participant record audio flag.

Args:

record_audio (bool): Participant record audio flag.

Returns:

ParticipantParams: Participant params with set record audio flag.

with_video_feed(video_feed: VideoFeed) ParticipantParams[source]

Set participant video feed.

Args:

video_feed (VideoFeed): Video feed.

Returns:

ParticipantParams: Participant params with set video feed.