Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scalekit/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import json
from math import floor
from typing import Any, Optional, Dict
Expand All @@ -14,6 +13,7 @@
from scalekit.connection import ConnectionClient
from scalekit.organization import OrganizationClient
from scalekit.directory import DirectoryClient
from scalekit.role import RoleClient
from scalekit.common.scalekit import (
AuthorizationUrlOptions,
CodeAuthenticationOptions,
Expand Down Expand Up @@ -55,6 +55,7 @@ def __init__(self, env_url: str, client_id: str, client_secret: str):
self.domain = DomainClient(self.core_client)
self.connection = ConnectionClient(self.core_client)
self.organization = OrganizationClient(self.core_client)
self.role = RoleClient(self.core_client)
self.directory = DirectoryClient(self.core_client)
except Exception as exp:
raise exp
Expand Down
128 changes: 128 additions & 0 deletions scalekit/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
from typing import Optional, List, Dict

from scalekit.core import CoreClient
from scalekit.v1.roles.roles_pb2 import *
from scalekit.v1.roles.roles_pb2_grpc import RolesServiceStub


class RoleClient:
"""Class definition for Role Client"""

def __init__(self, core_client: CoreClient):
"""
Initializer for Role Client

:param core_client : CoreClient Object
:type : ``` obj ```
:returns
None
"""
self.core_client = core_client
self.role_client = RolesServiceStub(
self.core_client.grpc_secure_channel
)

def list_organization_roles(
self, organization_id: str
) -> ListOrganizationRolesResponse:
"""
Method to list organization roles

:param organization_id : organization id
:type : ``` str ```
:returns:
list of organization roles
"""
return self.core_client.grpc_exec(
self.role_client.ListOrganizationRoles.with_call,
ListOrganizationRolesRequest(
org_id=organization_id
),
)

def create_organization_role(
self, organization_id: str, options: CreateRole
) -> CreateOrganizationRoleResponse:
"""
Method to create role in an organization based on given data

:param organization_id : organization id
:type : ``` str ```
:param options : Additional details for org role to be created
:type : ``` obj ```
:returns:
Create Organization Role Response
"""
return self.core_client.grpc_exec(
self.role_client.CreateOrganizationRole.with_call,
CreateOrganizationRoleRequest(
role=options,
org_id=organization_id
),
)

def update_organization_role(
self, organization_id: str, role_id: str, role: UpdateRole
) -> UpdateOrganizationRoleResponse:
"""
Method to update role in an organization based on given data

:param organization_id : Organization id of the role to update
:type : ``` str ```
:param role_id : Role id to update
:type : ``` str ```
:param role : Role object to update
:type : ``` obj ```
:returns:
Update Organization Role Response
"""
return self.core_client.grpc_exec(
self.role_client.UpdateOrganizationRole.with_call,
UpdateOrganizationRoleRequest(
org_id=organization_id,
id=role_id,
role=role
),
)

def delete_organization_role(
self, organization_id: str, role_id: str
) -> UpdateOrganizationRoleResponse:
"""
Method to delete role from an organization based on given data

:param organization_id : Organization id of the role to delete
:type : ``` str ```
:param role_id : Role id to delete
:type : ``` str ```
:returns:
None
"""
return self.core_client.grpc_exec(
self.role_client.DeleteOrganizationRole.with_call,
DeleteOrganizationRoleRequest(
org_id=organization_id,
id=role_id
),
)

def get_organization_role(
self, organization_id: str, role_id: str
) -> GetOrganizationRoleResponse:
"""
Method to get role in an organization based on given data

:param organization_id : Organization id of the role to delete
:type : ``` str ```
:param role_id : Role id to delete
:type : ``` str ```
:returns:
Get Organization Response
"""
return self.core_client.grpc_exec(
self.role_client.GetOrganizationRole.with_call,
GetOrganizationRoleRequest(
org_id=organization_id,
id=role_id
),
)
1 change: 0 additions & 1 deletion scalekit/utils/directory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from google.protobuf import message as _message
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf.internal import containers as _containers
Expand Down
Loading
Loading