Skip to content
Merged
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
4 changes: 3 additions & 1 deletion scalekit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from scalekit.organization import OrganizationClient
from scalekit.directory import DirectoryClient
from scalekit.users import UserClient
from scalekit.role import RoleClient
from scalekit.common.scalekit import (
AuthorizationUrlOptions,
CodeAuthenticationOptions,
Expand All @@ -25,7 +26,7 @@
from scalekit.constants.user import id_token_claim_to_user_map

AUTHORIZE_ENDPOINT = "oauth/authorize"
LOGOUT_ENDPOINT = "end_session"
LOGOUT_ENDPOINT = "oidc/logout"
webhook_tolerance_in_seconds = timedelta(minutes=5)
webhook_signature_version = "v1"

Expand Down Expand Up @@ -61,6 +62,7 @@ def __init__(self, env_url: str, client_id: str, client_secret: str):
self.directory = DirectoryClient(self.core_client)
self.m2m_client = M2MClient(self.core_client)
self.users = UserClient(self.core_client)
self.roles = RoleClient(self.core_client)
except Exception as exp:
raise exp

Expand Down
143 changes: 143 additions & 0 deletions scalekit/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
from typing import Optional

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_service = RolesServiceStub(
self.core_client.grpc_secure_channel
)

def create_role(
self,
env_id: str,
role: CreateRole
) -> CreateRoleResponse:
"""
Method to create a new role in the environment

:param env_id : Environment id to create role for
:type : ``` str ```
:param role : CreateRole object with expected values for role creation
:type : ``` obj ```

:returns:
Create Role Response
"""
return self.core_client.grpc_exec(
self.role_service.CreateRole.with_call,
CreateRoleRequest(
env_id=env_id,
role=role
),
)

def get_role(self, env_id: str, role_id: str) -> GetRoleResponse:
"""
Method to get role by ID

:param env_id : Environment id
:type : ``` str ```
:param role_id : Role id to get role details
:type : ``` str ```

:returns:
Get Role Response
"""
return self.core_client.grpc_exec(
self.role_service.GetRole.with_call,
GetRoleRequest(
env_id=env_id,
id=role_id
),
)

def list_roles(self, env_id: str) -> ListRolesResponse:
"""
Method to list all roles in environment

:param env_id : Environment id to list roles for
:type : ``` str ```

:returns:
List Roles Response
"""
return self.core_client.grpc_exec(
self.role_service.ListRoles.with_call,
ListRolesRequest(env_id=env_id),
)

def update_role(
self,
env_id: str,
role_id: str,
role: UpdateRole
) -> UpdateRoleResponse:
"""
Method to update an existing role by ID

:param env_id : Environment id
:type : ``` str ```
:param role_id : Role id to update
:type : ``` str ```
:param role : UpdateRole object with expected values for role update
:type : ``` obj ```

:returns:
Update Role Response
"""
return self.core_client.grpc_exec(
self.role_service.UpdateRole.with_call,
UpdateRoleRequest(
env_id=env_id,
id=role_id,
role=role
),
)

def delete_role(
self,
env_id: str,
role_id: str,
reassign_role_id: Optional[str] = None
):
"""
Method to delete role by ID

:param env_id : Environment id
:type : ``` str ```
:param role_id : Role id to be deleted
:type : ``` str ```
:param reassign_role_id: Role ID to reassign users to when deleting this role
:type : ``` str ```

:returns:
None
"""
request = DeleteRoleRequest(
env_id=env_id,
id=role_id
)
if reassign_role_id:
request.reassign_role_id = reassign_role_id

return self.core_client.grpc_exec(
self.role_service.DeleteRole.with_call,
request,
)


Empty file.
39 changes: 39 additions & 0 deletions scalekit/v1/auditlogs/auditlogs_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions scalekit/v1/auditlogs/auditlogs_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from buf.validate import validate_pb2 as _validate_pb2
from google.api import annotations_pb2 as _annotations_pb2
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from scalekit.v1.options import options_pb2 as _options_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor

class ListAuthLogRequest(_message.Message):
__slots__ = ("page_size", "page_token", "email", "status", "start_time", "end_time")
PAGE_SIZE_FIELD_NUMBER: _ClassVar[int]
PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int]
EMAIL_FIELD_NUMBER: _ClassVar[int]
STATUS_FIELD_NUMBER: _ClassVar[int]
START_TIME_FIELD_NUMBER: _ClassVar[int]
END_TIME_FIELD_NUMBER: _ClassVar[int]
page_size: int
page_token: str
email: str
status: str
start_time: _timestamp_pb2.Timestamp
end_time: _timestamp_pb2.Timestamp
def __init__(self, page_size: _Optional[int] = ..., page_token: _Optional[str] = ..., email: _Optional[str] = ..., status: _Optional[str] = ..., start_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., end_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...

class ListAuthLogResponse(_message.Message):
__slots__ = ("next_page_token", "total_size", "authRequests")
NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int]
TOTAL_SIZE_FIELD_NUMBER: _ClassVar[int]
AUTHREQUESTS_FIELD_NUMBER: _ClassVar[int]
next_page_token: str
total_size: int
authRequests: _containers.RepeatedCompositeFieldContainer[AuthLogRequest]
def __init__(self, next_page_token: _Optional[str] = ..., total_size: _Optional[int] = ..., authRequests: _Optional[_Iterable[_Union[AuthLogRequest, _Mapping]]] = ...) -> None: ...

class AuthLogRequest(_message.Message):
__slots__ = ("organization_id", "environment_id", "connection_id", "auth_request_id", "email", "connection_type", "connection_provider", "status", "timestamp")
ORGANIZATION_ID_FIELD_NUMBER: _ClassVar[int]
ENVIRONMENT_ID_FIELD_NUMBER: _ClassVar[int]
CONNECTION_ID_FIELD_NUMBER: _ClassVar[int]
AUTH_REQUEST_ID_FIELD_NUMBER: _ClassVar[int]
EMAIL_FIELD_NUMBER: _ClassVar[int]
CONNECTION_TYPE_FIELD_NUMBER: _ClassVar[int]
CONNECTION_PROVIDER_FIELD_NUMBER: _ClassVar[int]
STATUS_FIELD_NUMBER: _ClassVar[int]
TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
organization_id: str
environment_id: str
connection_id: str
auth_request_id: str
email: str
connection_type: str
connection_provider: str
status: str
timestamp: str
def __init__(self, organization_id: _Optional[str] = ..., environment_id: _Optional[str] = ..., connection_id: _Optional[str] = ..., auth_request_id: _Optional[str] = ..., email: _Optional[str] = ..., connection_type: _Optional[str] = ..., connection_provider: _Optional[str] = ..., status: _Optional[str] = ..., timestamp: _Optional[str] = ...) -> None: ...
66 changes: 66 additions & 0 deletions scalekit/v1/auditlogs/auditlogs_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from scalekit.v1.auditlogs import auditlogs_pb2 as scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2


class AuditLogsServiceStub(object):
"""Missing associated documentation comment in .proto file."""

def __init__(self, channel):
"""Constructor.

Args:
channel: A grpc.Channel.
"""
self.ListAuthRequests = channel.unary_unary(
'/scalekit.v1.auditlogs.AuditLogsService/ListAuthRequests',
request_serializer=scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2.ListAuthLogRequest.SerializeToString,
response_deserializer=scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2.ListAuthLogResponse.FromString,
)


class AuditLogsServiceServicer(object):
"""Missing associated documentation comment in .proto file."""

def ListAuthRequests(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_AuditLogsServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'ListAuthRequests': grpc.unary_unary_rpc_method_handler(
servicer.ListAuthRequests,
request_deserializer=scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2.ListAuthLogRequest.FromString,
response_serializer=scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2.ListAuthLogResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'scalekit.v1.auditlogs.AuditLogsService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))


# This class is part of an EXPERIMENTAL API.
class AuditLogsService(object):
"""Missing associated documentation comment in .proto file."""

@staticmethod
def ListAuthRequests(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/scalekit.v1.auditlogs.AuditLogsService/ListAuthRequests',
scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2.ListAuthLogRequest.SerializeToString,
scalekit_dot_v1_dot_auditlogs_dot_auditlogs__pb2.ListAuthLogResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Loading