igz_mgmt.resources

Contents

igz_mgmt.resources#

This module represents resources.

Most of the resources support all CRUD methods.

class igz_mgmt.resources.AccessKey(*, type: str = 'access_key', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, tenant_id: str = '', ttl: int = 315360000, created_at: str = '', updated_at: str = '', group_ids: List[str] = [], uid: int = 0, gids: List[int] = [], expires_at: int = 0, interface_kind: str = 'web', label: str = '', kind: str = 'accessKey', planes: List[SessionPlanes] = ['data', 'control'], **extra_data: Any)#

Bases: BaseResource

AccessKey resource represents access key in the system.

classmethod create(http_client: APIClient, planes: List[SessionPlanes] = ['data', 'control'], label: Optional[str] = None) AccessKey#

Creates a new access key.

Parameters:
  • http_client (APIClient) – The client to use.

  • planes (List[SessionPlanes], optional) – The planes of the access key.

  • label (str, optional) – The label of the access key.

created_at: str#
expires_at: int#
classmethod get_or_create(http_client: APIClient, planes: Optional[List[SessionPlanes]] = None, label: Optional[str] = None) AccessKey#

Get or create access key.

If access key with the given planes exists, it will be returned. Otherwise, a new access key will be created. If no planes are given, all planes will be used.

Parameters:
  • http_client (APIClient) – The client to use.

  • planes (List[SessionPlanes], optional) – The planes of the access key.

  • label (str, optional) – The label of the access key.

Returns:

An existing or newly created access key.

Return type:

AccessKey

gids: List[int]#
group_ids: List[str]#
interface_kind: str#
kind: str#
label: str#
planes: List[SessionPlanes]#
tenant_id: str#
ttl: int#
type: str#
uid: int#
updated_at: str#
class igz_mgmt.resources.AppServicesManifest(*, type: str = 'app_services_manifest', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, cluster_name: str = '', tenant_name: str = '', tenant_id: str = '', app_services: List[AppServiceBase] = [], state: Optional[AppServicesManifestStates] = None, last_error: Optional[str] = None, last_modification_job: str = '', apply_services_mode: Optional[ApplyServicesMode] = None, running_modification_job: str = '', force_apply_all_mode: Optional[ForceApplyAllMode] = None, **extra_data: Any)#

Bases: BaseResource

AppServicesManifest resource.

app_services: List[AppServiceBase]#
static apply_services(http_client: APIClient, force_apply_all_mode: ForceApplyAllMode = ForceApplyAllMode.disabled) ContextManager[AppServicesManifest]#

A context manager to apply services with multiple changes at once.

Parameters:
Returns:

The app service manifest instance.

Return type:

AppServicesManifest

apply_services_mode: Optional[ApplyServicesMode]#
cluster_name: str#
create_or_update(http_client: APIClient, app_service: Union[AppServiceSpec, AppServiceBase], wait_for_completion=True) Optional[Job]#

Creates or updates an app service.

Parameters:
  • http_client (APIClient) – The client to use.

  • app_service (AppServiceSpec or AppServiceBase) – The app service to create or update

  • wait_for_completion (bool) – Whether to wait for the job to complete

Returns:

the job that was created or None if wait_for_completion is False.

Return type:

Job, optional

delete(http_client: APIClient, **kwargs) Optional[Job]#

This method is forbidden.

force_apply_all_mode: Optional[ForceApplyAllMode]#
classmethod get(http_client: APIClient, **kwargs) AppServicesManifest#

Gets the app services manifest from the API.

Parameters:
  • http_client (APIClient) – The client to use.

  • **kwargs – Arbitrary keyword arguments (not in used).

Returns:

The app service manifest instance.

Return type:

AppServicesManifest

last_error: Optional[str]#
last_modification_job: str#
list(http_client: APIClient, **kwargs)#

This method is forbidden.

remove_service(http_client: APIClient, app_service_spec_name: str, wait_for_completion=True) Optional[Job]#

Removes an app service.

Parameters:
  • http_client (APIClient) – The client to use.

  • app_service_spec_name (str) – Name of the app service to remove

  • wait_for_completion (bool) – Whether to wait for the job to complete

Returns:

the job that was created or None if wait_for_completion is False.

Return type:

Job, optional

resolve_service(app_service_spec_name: str) Optional[AppServiceBase]#

Gets the app service that matches the given spec name.

Parameters:

app_service_spec_name (str) – The name of the app service spec.

Returns:

The app service instance that matches the given spec name.

Return type:

AppServiceBase, optional

restart(http_client: APIClient, app_service_spec_name: str, wait_for_completion=True) Optional[Job]#

Restarts an app service.

Parameters:
  • http_client (APIClient) – The client to use.

  • app_service_spec_name (str) – Name of the app service to restart

  • wait_for_completion (bool) – Whether to wait for the job to complete

Returns:

the job that was created or None if wait_for_completion is False.

Return type:

Job, optional

running_modification_job: str#
scale_from_zero(http_client: APIClient, app_service_spec_name: str, wait_for_completion=True) Optional[Job]#

Scales an app service from zero.

Parameters:
  • http_client (APIClient) – The client to use.

  • app_service_spec_name (str) – Name of the app service to scale from zero

  • wait_for_completion (bool) – Whether to wait for the job to complete

Returns:

the job that was created or None if wait_for_completion is False.

Return type:

Job, optional

set_apply_mode(apply_mode: ApplyServicesMode)#

Sets the apply mode of the app services manifest.

Parameters:

apply_mode (ApplyServicesMode) – apply services mode value.

state: Optional[AppServicesManifestStates]#
tenant_id: str#
tenant_name: str#
type: str#
update(http_client: APIClient, **kwargs)#

This method is forbidden.

class igz_mgmt.resources.AuditEvent(*, type: Optional[str] = 'audit_event', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, source: str = '', kind: str = '', timestamp_uint64: Optional[int] = None, timestamp_iso8601: Optional[str] = None, timestamp_uint64_str: Optional[str] = None, parameters_uint64: Optional[List[ParametersUint64]] = None, parameters_text: Optional[List[ParametersText]] = None, description: Optional[str] = None, severity: Optional[EventSeverity] = None, tags: Optional[List[str]] = None, affected_resources: Optional[List[AffectedResource]] = None, classification: Optional[EventClassification] = None, system_event: Optional[bool] = False, visibility: Optional[EventVisibility] = None, **extra_data: Any)#

Bases: Event

AuditEvent resource represents audit events in the system.

Audit events are used to represent user and system actions within the system

classmethod delete_all(http_client: APIClient)#

Deleting audit events are not supported.

emit(http_client, **kwargs)#

Emit the event.

Requires system-admin role.

Parameters:

http_client – HTTP client to use

type: Optional[str]#
class igz_mgmt.resources.BaseResource(*, type: str, id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, **extra_data: Any)#

Bases: ResourceBaseModel

Base resource contains common attributes and methods for resources in the system.

delete(http_client: APIClient, ignore_missing: bool = False, wait_for_job_deletion: bool = True) Optional[Job]#

Deletes resource record.

Parameters:
  • http_client (APIClient) – The client to use.

  • ignore_missing (bool, optional) – When True, don’t raise an exception in case the record does not exist.

  • default. (False by) –

  • wait_for_job_deletion (bool, optional) – Whether to wait for the job to complete. True by default.

Returns:

the job that was created or None.

Return type:

Job, optional

classmethod get(http_client: APIClient, resource_id: Union[int, str], include: Optional[List[str]] = None) BaseResource#

Gets the resource record.

Parameters:
  • http_client (APIClient) – The client to use.

  • resource_id (int or str) – Record id.

  • include (List[str], optional) – Include related resources. None by default.

Returns:

The resource record.

Return type:

BaseResource

id: Optional[Union[int, str]]#
included: Optional[List[ResourceBaseModel]]#
classmethod list(http_client: APIClient, filter_by: Optional[Mapping[str, str]] = None, sort_by: Optional[List[str]] = None, paging: Optional[ResourceListPagingQueryParams] = None, include: Optional[List[str]] = None) List[BaseResource]#

Lists resource records.

Parameters:
  • http_client (APIClient) – The client to use.

  • filter_by (Mapping[str, str], optional) – Filter by field values. None by default.

  • sort_by (List[str], optional) – Sort by field names. None by default.

  • paging (ResourceListPagingQueryParams, optional) – Allow to paginate resource by given records size.

  • default. (None by) –

  • include (List[str], optional) – Include related resources. None by default.

Returns:

List of records for the specific resource.

Return type:

List[BaseResource]

relationships: Optional[dict]#
type: str#
update(http_client: APIClient, relationships=None, **kwargs) BaseResource#

Updates resource record.

Parameters:
  • http_client (APIClient) – The client to use.

  • relationships (optional) – The resource relationships. None by default.

  • **kwargs – additional arguments to pass to the request.

Returns:

The updated record.

Return type:

BaseResource

class igz_mgmt.resources.CommunicationEvent(*, type: str = 'communication_event', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, source: str = '', kind: str = '', timestamp_uint64: Optional[int] = None, timestamp_iso8601: Optional[str] = None, timestamp_uint64_str: Optional[str] = None, parameters_uint64: Optional[List[ParametersUint64]] = None, parameters_text: Optional[List[ParametersText]] = None, description: Optional[str] = None, severity: Optional[EventSeverity] = None, tags: Optional[List[str]] = None, affected_resources: Optional[List[AffectedResource]] = None, classification: Optional[EventClassification] = None, system_event: Optional[bool] = False, visibility: Optional[EventVisibility] = None, **extra_data: Any)#

Bases: Event

CommunicationEvent resource represents internal communication events in the system.

Communication events are used to communicate between internal components within the system. Their visibility is internal and the classification is usually “sw”.

affected_resources: Optional[List[AffectedResource]]#
classification: Optional[EventClassification]#
description: Optional[str]#
kind: str#
parameters_text: Optional[List[ParametersText]]#
parameters_uint64: Optional[List[ParametersUint64]]#
severity: Optional[EventSeverity]#
source: str#
system_event: Optional[bool]#
tags: Optional[List[str]]#
timestamp_iso8601: Optional[str]#
timestamp_uint64: Optional[int]#
timestamp_uint64_str: Optional[str]#
type: Optional[str]#
visibility: Optional[EventVisibility]#
class igz_mgmt.resources.Event(*, type: Optional[str] = 'event', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, source: str = '', kind: str = '', timestamp_uint64: Optional[int] = None, timestamp_iso8601: Optional[str] = None, timestamp_uint64_str: Optional[str] = None, parameters_uint64: Optional[List[ParametersUint64]] = None, parameters_text: Optional[List[ParametersText]] = None, description: Optional[str] = None, severity: Optional[EventSeverity] = None, tags: Optional[List[str]] = None, affected_resources: Optional[List[AffectedResource]] = None, classification: Optional[EventClassification] = None, system_event: Optional[bool] = False, visibility: Optional[EventVisibility] = None, **extra_data: Any)#

Bases: BaseResource

Event resource represents events in the system.

Events are used to notify about changes in the system.

affected_resources: Optional[List[AffectedResource]]#
classification: Optional[EventClassification]#
delete(http_client: APIClient, ignore_missing: bool = False, wait_for_job_deletion: bool = True) Optional[Job]#

Deleting a single event is not supported.

classmethod delete_all(http_client: APIClient)#

Delete all events.

Requires Iguazio privileged user.

Parameters:

http_client (APIClient) – The client to use.

description: Optional[str]#
emit(http_client, **kwargs)#

Emit the event.

Requires system-admin role.

Parameters:

http_client – HTTP client to use

classmethod get(http_client: APIClient, resource_id: Union[int, str], include: Optional[List[str]] = None) BaseResource#

Getting an event is not supported.

kind: str#
parameters_text: Optional[List[ParametersText]]#
parameters_uint64: Optional[List[ParametersUint64]]#
severity: Optional[EventSeverity]#
source: str#
system_event: Optional[bool]#
tags: Optional[List[str]]#
timestamp_iso8601: Optional[str]#
timestamp_uint64: Optional[int]#
timestamp_uint64_str: Optional[str]#
type: Optional[str]#
update(http_client: APIClient, relationships=None, **kwargs) BaseResource#

Updating an event is not supported.

visibility: Optional[EventVisibility]#
class igz_mgmt.resources.Group(*, type: str = 'user_group', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, name: str = '', description: str = None, data_access_mode: str = 'enabled', gid: int = 0, kind: str = 'local', assigned_policies: List[TenantManagementRoles] = [], system_provided: bool = False, **extra_data: Any)#

Bases: BaseResource, ProjectMembershipResource

Group resource represents user group in the system.

add_user(http_client: APIClient, user: Union[str, int, User])#

Adds a user to group.

  1. get the user

  2. add the group to the user

  3. update the group

Parameters:
  • http_client (APIClient) – The client to use.

  • user (str or int or User) – The user id or username or user instance to add.

assigned_policies: List[TenantManagementRoles]#
classmethod create(http_client: APIClient, name: Optional[str], assigned_policies: Optional[List[TenantManagementRoles]] = None, description: Optional[str] = None, gid: Optional[int] = None, users: Optional[List[Union[int, str, User]]] = None) Group#

Creates a new group.

Parameters:
  • http_client (APIClient) – The client to use.

  • name (str, optional) – Group name.

  • assigned_policies (List[TenantManagementRoles], optional) – The assigned policies of the group.

  • default. (to add to the group. None by) –

  • description (str, optional) – The description of the group. None by default.

  • gid (int, optional) – The gid of the group (leave empty for auto-assign). None by default.

  • users (List[Union[int, str, User]], optional) – A list of User objects or user ids

  • default.

Returns:

Group

data_access_mode: str#
description: str#
classmethod get_by_name(http_client: APIClient, name: str, include=None) Group#

A convenience method to get a group by name.

Parameters:
  • http_client (APIClient) – The client to use.

  • name (str) – Group name.

  • include (optional) – Include related resources. None by default.

Returns:

The group instance by group name.

Return type:

Group

Raises:

ResourceNotFoundException – If group is not found

gid: int#
kind: str#
name: str#
remove_user(http_client: APIClient, user: Union[str, int, User], force=False)#

Removes a user from group.

Parameters:
  • http_client (APIClient) – The client to use.

  • user (str ot int or User) – The user id or username or user instance to remove.

  • force (bool) – force (bool): Whether to force the removal of the user from the group(for example, from its primary group).

system_provided: bool#
type: str#
class igz_mgmt.resources.Job(*, type: str = 'job', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, kind: str = '', params: str = '', max_total_execution_time: int = 10800, max_worker_execution_time: Optional[int] = None, delay: float = 0, state: JobStates = JobStates.created, result: str = '', created_at: str = '', on_success: List[dict] = None, on_failure: List[dict] = None, updated_at: str = '', handler: str = '', ctx_id: str = '', **extra_data: Any)#

Bases: BaseResource

Job is an abstraction for long-running operations in the API.

Some operations, cannot be finished within a reasonable amount of time for a normal HTTP request. Job has a state, id and can be awaited on asynchronously.

created_at: str#
ctx_id: str#
delay: float#
delete(http_client: APIClient, **kwargs) Optional[Job]#

This method is forbidden.

handler: str#
kind: str#
max_total_execution_time: int#
max_worker_execution_time: Optional[int]#
on_failure: List[dict]#
on_success: List[dict]#
params: str#
result: str#
state: JobStates#
type: str#
update(http_client: APIClient, **kwargs)#

This method is forbidden.

updated_at: str#
static wait_for_completion(http_client: APIClient, job_id: str, job_completion_retry_interval: float = 30, timeout: int = 3600)#

Wait for a job to be finished.

Parameters:
  • http_client (APIClient) – The client to use.

  • job_id (str) – The job id.

  • job_completion_retry_interval (float, optional) – The default is 30.

  • timeout (int, optional) – The default is 3600.

class igz_mgmt.resources.Project(*, type: str = 'project', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, name: str = '', description: str = '', created_at: str = '', updated_at: str = '', admin_status: str = ProjectAdminStatuses.online, operational_status: str = ProjectOperationalStatuses.creating, labels: List[Dict[str, str]] = [], annotations: List[Dict[str, str]] = [], default_function_node_selector: List[Dict[str, str]] = [], mlrun_project: str = '', nuclio_project: str = '', **extra_data: Any)#

Bases: BaseResource

Project resource represents project in the system.

add_members(http_client: APIClient, members: List[Union[User, Group]], role: ProjectAuthorizationRoles, wait_for_job: bool = True, notify_by_email: bool = False, add_member_mode: AddMemberMode = AddMemberMode.fail_on_existing)#

Adds members to the project.

Parameters:
  • http_client (APIClient) – The client to use.

  • members (List[User or Group]) – User instances or Group instances.

  • role (ProjectAuthorizationRolesTypes) – The role name.

  • wait_for_job (bool, optional) – Wait for job completion. Defaults to True.

  • notify_by_email (bool, optional) – Notify by email. Defaults to False.

  • add_member_mode (AddMemberModes, optional) – Add member mode. Defaults to AddMemberModes.fail_on_existing.

admin_status: str#
annotations: List[Dict[str, str]]#
classmethod annotations_validator(value)#

Validate project annotations field value.

apply_authorization_roles(http_client: APIClient, wait_for_job: bool = True, notify_by_email: bool = False) ContextManager[ProjectAuthorizationRoleSet]#

Returns a context manager that applies the authorization roles.

Parameters:
  • http_client (APIClient) – The client to use.

  • wait_for_job (bool, optional) – Wait for job completion. Defaults to True.

  • notify_by_email (bool, optional) – Notify by email. Defaults to False.

Yields:

ProjectAuthorizationRoleSet – The project authorization roles.

classmethod create(http_client: APIClient, name: str, description: str = '', labels: Optional[List[Dict[str, str]]] = None, annotations: Optional[List[Dict[str, str]]] = None, owner: Optional[Union[str, User]] = None, wait_for_completion=True, default_function_node_selector: Optional[List[Dict[str, str]]] = None) Project#

Creates a new project.

Parameters:
  • http_client (APIClient) – The client to use.

  • name (str) – The project name.

  • description (str, optional) – The project description.

  • labels (List[Dict[str, str]], optional) – The project labels.

  • annotations (List[Dict[str, str]], optional) – The project annotations.

  • owner (str or User or None) – The project owner. None by default

  • wait_for_completion (bool) – Whether to wait for the job to complete

  • default_function_node_selector (List[Dict[str, str]], optional) – The default node

  • project. (selectors to be used for functions in the) –

Returns:

The project instance.

Return type:

Project

created_at: str#
default_function_node_selector: List[Dict[str, str]]#
classmethod default_function_node_selector_validator(value)#

Validate project default_function_node_selector field value.

delete(http_client: APIClient, ignore_missing: bool = False, wait_for_job_deletion: bool = True, deletion_strategy: Optional[ProjectDeletionStrategies] = None) Optional[Job]#

Deletes resource record.

Parameters:
  • http_client (APIClient) – The client to use.

  • ignore_missing (bool, optional) – When True, don’t raise an exception in case the record does not exist.

  • default. (False by) –

  • wait_for_job_deletion (bool, optional) – Whether to wait for the job to complete. True by default.

  • deletion_strategy (ProjectDeletionStrategies, optional) – The project deletion type. None by default

Returns:

the job that was created or None.

Return type:

Job, optional

description: str#
get_admin_groups()#

Returns the project admin groups.

get_admin_users()#

Returns the project admin users.

classmethod get_by_name(http_client: APIClient, name: str, include: Optional[List[str]] = None) Project#

A convenience method to get a project by name.

Parameters:
  • http_client (APIClient) – The client to use.

  • name (str) – The project name.

  • include (List[str], optional) – Include related resources (e.g. include=[“tenant”, “owner”]). None by default.

Returns:

The project instance by name.

Return type:

Project

Raises:

ResourceNotFoundException – If project is not found

get_editor_groups()#

Returns the project editor groups.

get_editor_users()#

Returns the project editor users.

get_owner(http_client: APIClient) Optional[User]#

Returns the project owner.

Parameters:

http_client (APIClient) – The client to use.

Returns:

The project owner.

Return type:

User

get_user_effective_role(http_client: APIClient, user: Union[str, User]) Optional[ProjectAuthorizationRoles]#

Returns the effective role of the user.

Parameters:
  • http_client (APIClient) – The client to use.

  • user (str or User) – The user id or username or user instance.

Returns:

The effective role of the user.

Return type:

str

get_viewer_groups()#

Returns the project viewer groups.

get_viewer_users()#

Returns the project viewer users.

labels: List[Dict[str, str]]#
classmethod labels_validator(value)#

Validate project labels field value.

mlrun_project: str#
name: str#
nuclio_project: str#
operational_status: str#
remove_member(http_client: APIClient, member: Union[User, Group, ProjectMembershipResource], wait_for_job: bool = True, notify_by_email: bool = False)#

Removes a member from the project.

Parameters:
  • http_client (APIClient) – The client to use.

  • member (User or Group) – User instance or Group instance.

  • wait_for_job (bool, optional) – Wait for job completion. Defaults to True.

  • notify_by_email (bool, optional) – Notify by email. Defaults to False.

remove_members(http_client: APIClient, members: List[Union[User, Group]], wait_for_job: bool = True, notify_by_email: bool = False)#

Removes members from the project.

Parameters:
  • http_client (APIClient) – The client to use.

  • members (List[User or Group]) – User instances or Group instances.

  • wait_for_job (bool, optional) – Wait for job completion. Defaults to True.

  • notify_by_email (bool, optional) – Notify by email. Defaults to False.

resolve_member_role(member: Union[User, Group])#

Returns the member role.

Parameters:

member (User or Group) – User instance or Group instance.

Returns:

The member role.

Return type:

ProjectAuthorizationRolesTypes

set_members(http_client: APIClient, members: List[Union[User, Group]], role: ProjectAuthorizationRoles, wait_for_job: bool = True, notify_by_email: bool = False, override: bool = False)#

Overrides the existing role members with the given members.

Parameters:
  • http_client (APIClient) – The client to use.

  • members (List[User or Group]) – User instances or Group instances.

  • role (ProjectAuthorizationRolesTypes) – The role name.

  • wait_for_job (bool, optional) – Wait for job completion. Defaults to True.

  • notify_by_email (bool, optional) – Notify by email. Defaults to False.

  • override (bool, optional) – Override existing members. Defaults to False.

set_membership(http_client: APIClient, member: Union[User, Group, ProjectMembershipResource], role: ProjectAuthorizationRoles, wait_for_job: bool = True, notify_by_email: bool = False, add_member_mode: AddMemberMode = AddMemberMode.fail_on_existing)#

Adds a member to the project.

Parameters:
  • http_client (APIClient) – The client to use.

  • member (User or Group) – User instance or Group instance.

  • role (ProjectAuthorizationRolesTypes) – The role name.

  • wait_for_job (bool, optional) – Wait for job completion. Defaults to True.

  • notify_by_email (bool, optional) – Notify by email. Defaults to False.

  • add_member_mode (AddMemberModes, optional) – Add member mode. Defaults to AddMemberModes.fail_on_existing.

set_owner(http_client: APIClient, owner: Union[str, User])#

Sets the owner of the project.

Parameters:
  • http_client (APIClient) – The client to use.

  • owner (str or User) – The user id or user name or user instance.

Returns:

The project instance.

Return type:

Project

type: str#
update(http_client: APIClient, relationships=None, **kwargs) BaseResource#

Updates project.

Parameters:
  • http_client (APIClient) – The client to use.

  • relationships (optional) – The project relationships. None by default.

  • **kwargs – additional arguments to pass to the request.

Returns:

The updated record.

Return type:

BaseResource

updated_at: str#
class igz_mgmt.resources.ProjectAuthorizationRole(*, type: str = 'project_authorization_role', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, name: ProjectAuthorizationRoles, users: Optional[List[User]] = [], groups: Optional[List[Group]] = [], project_id: str, **extra_data: Any)#

Bases: BaseResource

ProjectAuthorizationRole resource represents project authorization role in the system.

groups: Optional[List[Group]]#
name: ProjectAuthorizationRoles#
project_id: str#
type: str#
users: Optional[List[User]]#
class igz_mgmt.resources.ProjectAuthorizationRoleSet(*, type: str = 'authorization_role', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, roles: Optional[Dict[str, ProjectAuthorizationRole]] = {}, **extra_data: Any)#

Bases: BaseResource

ProjectAuthorizationRoleSet resource represents the set of authorization roles on a certain project.

add_member_to_role(http_client: APIClient, member: Union[User, Group], role: ProjectAuthorizationRoles, add_member_mode: AddMemberMode = AddMemberMode.fail_on_existing)#

Add a member to a specific role.

Parameters:
add_members_to_role(http_client: APIClient, members: List[Union[User, Group]], role: ProjectAuthorizationRoles, add_member_mode: AddMemberMode = AddMemberMode.fail_on_existing)#

Add members to a specific role.

Parameters:
apply(http_client: APIClient, wait_for_job: bool = True, notify_by_email: bool = False) ContextManager[ProjectAuthorizationRoleSet]#

Apply the changes made to the roles.

This function allows multiple membership changes with a single api call by context manager. It sets skip apply, yields itself for the context manager so user can run any function without applying, sets the value back and applies when context manager exists.

Parameters:
  • http_client (igz_mgmt.client.APIClient) – The client to use.

  • wait_for_job (bool, optional) – Whether to wait for the job to finish. Defaults to True.

  • notify_by_email (bool, optional) – Whether to notify by email. Defaults to False.

Yields:

ProjectAuthorizationRoleSet – The updated role set.

get_roles(role: ProjectAuthorizationRoles, member_kind) List[Union[User, Group]]#

Get all members of a specific role.

Parameters:
Returns:

A list of members(instances of User/Group).

Return type:

list

remove_member(http_client: APIClient, member: Union[User, Group])#

Remove a member from the roles.

Parameters:
remove_members(http_client: APIClient, members: List[Union[User, Group]])#

Remove members.

Parameters:
resolve_member_role(member: Union[User, Group]) Optional[ProjectAuthorizationRole]#

Find a member in the roles.

Parameters:

member (Union[User, Group]) – The member to find.

Returns:

The role that the member belongs to.

Return type:

ProjectAuthorizationRole

roles: Optional[Dict[str, ProjectAuthorizationRole]]#
set_members(http_client: APIClient, members: List[Union[User, Group]], role: ProjectAuthorizationRoles)#

Overrides the existing role members with the given members.

Parameters:
type: str#
class igz_mgmt.resources.ProjectMembershipResource#

Bases: BaseModel

Base class for project membership resources.

ensure_project_membership(http_client: APIClient, project_name: str, role: ProjectAuthorizationRoles)#

Ensures that the current object is a member of a project with a specific role.

Parameters:
  • http_client (APIClient) – The client to use.

  • project_name (str) – The project name.

  • role (ProjectAuthorizationRolesNames) – The role name.

remove_from_project(http_client: APIClient, project_name: str)#

Removes current object from a project.

Parameters:
  • http_client (APIClient) – The client to use.

  • project_name (str) – The project name.

class igz_mgmt.resources.ResourceBaseModel(*, type: str, id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, **extra_data: Any)#

Bases: BaseModel

Base model for all resources.

class Config#

Bases: object

extra = 'allow'#
getter_dict#

alias of _BaseGetter

orm_mode = True#
underscore_attrs_are_private = True#
use_enum_values = True#
validate_assignment = True#
classmethod from_orm_with_client(http_client, *args, **kwargs)#

Creates a new instance from an ORM object and init the http client.

id: Optional[Union[int, str]]#
included: Optional[List[ResourceBaseModel]]#
relationships: Optional[dict]#
type: str#
class igz_mgmt.resources.User(*, type: str = 'user', id: Optional[Union[int, str]] = None, relationships: Optional[dict] = None, included: Optional[List[ResourceBaseModel]] = None, username: str = '', first_name: str = '', last_name: str = '', email: str = '', uid: int = 0, created_at: str = '', data_access_mode: str = '', authentication_scheme: str = '', authentication_methods: List[UserAuthenticationMethods] = [], send_password_on_creation: bool = False, assigned_policies: List[TenantManagementRoles] = [], operational_status: str = UserOperationalStatuses.up, admin_status: str = UserAdminStatuses.up, password: SecretStr = None, phone_number: str = '', job_title: str = '', department: str = '', last_activity: str = '', **extra_data: Any)#

Bases: BaseResource, ProjectMembershipResource

User resource represents user in the system.

add_to_group(http_client: APIClient, group: Union[str, Group])#

Adds a user to a group.

  1. get the user

  2. add the group to the user

  3. update the user

Parameters:
  • http_client (APIClient) – The client to use.

  • group (str or Group) – The group id or group name or group instance to add user into it.

admin_status: str#
assigned_policies: List[TenantManagementRoles]#
authentication_methods: List[UserAuthenticationMethods]#
authentication_scheme: str#
classmethod create(http_client: APIClient, username: str, email: str, first_name: str, last_name: str, password: Optional[str] = None, uid: Optional[int] = None, assigned_policies: Optional[List[TenantManagementRoles]] = None, primary_group: Optional[Union[str, Group]] = None, groups: Optional[Union[List[str], List[Group]]] = None, timeout: int = 30, wait_for_completion=True, phone_number: str = '', job_title: str = '', department: str = '', authentication_methods: Optional[UserAuthenticationMethods] = None) User#

Creates a new User.

Parameters:
  • http_client (APIClient) – The client to use.

  • username (str) – The user username.

  • password (str, optional) – The user password. None by default. (if not provided, an email is automatically

  • password) (sent to the user to set his) –

  • assigned_policies (List[TenantManagementRoles], optional) – The assigned policies of the group.

  • default. (type to log in with. None by) –

  • primary_group (str or Group or None) – None by default.

  • groups (Union[List[str], List["Group"], None], optional) – A list of group objects

  • default.

  • timeout (int, optional) – The default is 30.

  • wait_for_completion (bool) – Whether to wait for the job to complete

  • phone_number (str, optional) – The user phone number.

  • job_title (str, optional) – The user job title.

  • department (str, optional) – The user department.

  • authentication_methods (List[UserAuthenticationMethods], optional) – The authentication method

  • default.

Returns:

User

created_at: str#
data_access_mode: str#
department: str#
disable(http_client: APIClient)#

Disables the user instance.

Parameters:

http_client (APIClient) – The client to use.

classmethod disable_by_id(http_client: APIClient, user_id: str)#

Disables the user by user id.

Parameters:
  • http_client (APIClient) – The client to use.

  • user_id (str) – The user id.

classmethod disable_by_username(http_client: APIClient, username: str)#

Disables the user by username.

Parameters:
  • http_client (APIClient) – The client to use.

  • username (str) – The user username.

classmethod disable_user(http_client: APIClient, user: Union[str, int, User])#

Disables the user.

Parameters:
  • http_client (APIClient) – The client to use.

  • user (str or int or User) – The user id, username or user instance.

email: str#
enable(http_client: APIClient)#

Enables the user instance.

Parameters:

http_client (APIClient) – The client to use.

classmethod enable_by_id(http_client: APIClient, user_id: str)#

Enables the user by user id.

Parameters:
  • http_client (APIClient) – The client to use.

  • user_id (str) – The user id.

classmethod enable_by_username(http_client: APIClient, username: str)#

Enables the user by username.

Parameters:
  • http_client (APIClient) – The client to use.

  • username (str) – The user username.

classmethod enable_user(http_client: APIClient, user: Union[str, int, User])#

Enables the user.

Parameters:
  • http_client (APIClient) – The client to use.

  • user (str or int or User) – The user id, username or user instance.

first_name: str#
classmethod get_by_username(http_client: APIClient, username: str, include=None) User#

A convenience method to get a user by username.

Parameters:
  • http_client (APIClient) – The client to use.

  • username (str) – The user username.

  • include (optional) – Include related resources. None by default.

Returns:

The user instance by username.

Return type:

User

Raises:

ResourceNotFoundException – If user is not found

get_primary_group(http_client: APIClient) Optional[Group]#

Gets the primary group of a user.

Parameters:

http_client (APIClient) – The client to use.

Returns:

The primary group of the user.

Return type:

Group

get_project_effective_role(http_client: APIClient, project_name: str)#

Gets the effective roles of the user in a project.

Parameters:
  • http_client (APIClient) – The client to use.

  • project_name (str) – The project name.

Returns:

The effective roles of the user in the project.

Return type:

list

in_group(http_client: APIClient, group: Union[str, Group])#

Checks if user is part of a group.

Parameters:
  • http_client (APIClient) – The client to use.

  • group (str or Group) – The group id or group instance to check if user is part of it.

Returns:

True if user is part of the group, False otherwise.

Return type:

bool

is_operational(http_client: APIClient)#

Verify user is operational.

Verifying that the user operational status is up and that the all_users group exists in the user_groups relationships.

Parameters:

http_client (APIClient) – The client to use.

Returns:

True if user is operational, False otherwise.

Return type:

bool

job_title: str#
last_activity: str#
last_name: str#
operational_status: str#
password: SecretStr#
phone_number: str#
remove_from_group(http_client: APIClient, group: Union[str, Group], force=False)#

Removes a user from a group.

Parameters:
  • http_client (APIClient) – The client to use.

  • group (str or Group) – The group id or group name or group instance to remove user from it.

  • force (bool) – force (bool): Whether to force the removal of the user from the group (for example, from its primary group).

classmethod self(http_client: APIClient) User#

Gets the current user.

Parameters:

http_client (APIClient) – The client to use.

Returns:

The current user instance.

Return type:

User

send_password_on_creation: bool#
set_primary_group(http_client: APIClient, group: Union[str, Group])#

Sets the primary group of a user.

Parameters:
  • http_client (APIClient) – The client to use.

  • group (str or Group) – The primary group id or group name or group instance.

type: str#
uid: int#
username: str#