コード例 #1
0
    async def get_group(self, groupId):
        """
        Lists all group rules for your organization.
        Args:
            group_id {str}
        Returns:
            Group
        """
        http_method = "get".upper()
        api_url = format_url(f"""
            {self._base_url}
            /api/v1/groups/{groupId}
            """)

        body = {}
        headers = {}

        request, error = await self._request_executor.create_request(
            http_method, api_url, body, headers)

        if error:
            return (None, None, error)

        response, error = await self._request_executor\
            .execute(request, Group)

        if error:
            return (None, response, error)

        try:
            result = Group(self.form_response_body(response.get_body()))
        except Exception as error:
            return (None, response, error)
        return (result, response, None)
コード例 #2
0
ファイル: group_client.py プロジェクト: okta/okta-sdk-python
    async def list_group_targets_for_group_role(self,
                                                groupId,
                                                roleId,
                                                query_params={},
                                                keep_empty_params=False):
        """
        Args:
            group_id {str}
            role_id {str}
            query_params {dict}: Map of query parameters for request
            [query_params.after] {str}
            [query_params.limit] {str}
        Returns:
            list: Collection of Group instances.
        """
        http_method = "get".upper()
        api_url = format_url(f"""
            {self._base_url}
            /api/v1/groups/{groupId}/roles/{roleId}/targets
                /groups
            """)
        if query_params:
            encoded_query_params = urlencode(query_params)
            api_url += f"/?{encoded_query_params}"

        body = {}
        headers = {}
        form = {}

        request, error = await self._request_executor.create_request(
            http_method,
            api_url,
            body,
            headers,
            form,
            keep_empty_params=keep_empty_params)

        if error:
            return (None, None, error)

        response, error = await self._request_executor\
            .execute(request, Group)

        if error:
            return (None, response, error)

        try:
            result = []
            for item in response.get_body():
                result.append(Group(self.form_response_body(item)))
        except Exception as error:
            return (None, response, error)
        return (result, response, None)
コード例 #3
0
ファイル: group_client.py プロジェクト: okta/okta-sdk-python
    async def list_groups(self, query_params={}, keep_empty_params=False):
        """
        Enumerates groups in your organization with pagination.
        A subset of groups can be returned that match a suppor
        ted filter expression or query.
        Args:
            query_params {dict}: Map of query parameters for request
            [query_params.q] {str}
            [query_params.search] {str}
            [query_params.after] {str}
            [query_params.limit] {str}
            [query_params.expand] {str}
        Returns:
            list: Collection of Group instances.
        """
        http_method = "get".upper()
        api_url = format_url(f"""
            {self._base_url}
            /api/v1/groups
            """)
        if query_params:
            encoded_query_params = urlencode(query_params)
            api_url += f"/?{encoded_query_params}"

        body = {}
        headers = {}
        form = {}

        request, error = await self._request_executor.create_request(
            http_method,
            api_url,
            body,
            headers,
            form,
            keep_empty_params=keep_empty_params)

        if error:
            return (None, None, error)

        response, error = await self._request_executor\
            .execute(request, Group)

        if error:
            return (None, response, error)

        try:
            result = []
            for item in response.get_body():
                result.append(Group(self.form_response_body(item)))
        except Exception as error:
            return (None, response, error)
        return (result, response, None)
コード例 #4
0
ファイル: group_client.py プロジェクト: okta/okta-sdk-python
    async def update_group(self, groupId, group, keep_empty_params=False):
        """
        Updates the profile for a group with `OKTA_GROUP` type
        from your organization.
        Args:
            group_id {str}
            {group}
        Returns:
            Group
        """
        http_method = "put".upper()
        api_url = format_url(f"""
            {self._base_url}
            /api/v1/groups/{groupId}
            """)

        if isinstance(group, dict):
            body = group
        else:
            body = group.as_dict()
        headers = {
            "Accept": "application/json",
            "Content-Type": "application/json"
        }
        form = {}

        request, error = await self._request_executor.create_request(
            http_method,
            api_url,
            body,
            headers,
            form,
            keep_empty_params=keep_empty_params)

        if error:
            return (None, None, error)

        response, error = await self._request_executor\
            .execute(request, Group)

        if error:
            return (None, response, error)

        try:
            result = Group(self.form_response_body(response.get_body()))
        except Exception as error:
            return (None, response, error)
        return (result, response, None)
コード例 #5
0
    async def create_group(
            self, group
    ):
        """
        Adds a new group with `OKTA_GROUP` type to your organiz
        ation.
        Args:
            {group}
        Returns:
            Group
        """
        http_method = "post".upper()
        api_url = format_url(f"""
            {self._base_url}
            /api/v1/groups
            """)

        if isinstance(group, dict):
            body = group
        else:
            body = group.as_dict()
        headers = {
            "Accept": "application/json",
            "Content-Type": "application/json"
        }

        request, error = await self._request_executor.create_request(
            http_method, api_url, body, headers
        )

        if error:
            return (None, None, error)

        response, error = await self._request_executor\
            .execute(request, Group)

        if error:
            return (None, response, error)

        try:
            result = Group(
                self.form_response_body(response.get_body())
            )
        except Exception as error:
            return (None, response, error)
        return (result, response, None)
コード例 #6
0
ファイル: group_client.py プロジェクト: okta/okta-sdk-python
    async def get_group(self, groupId, keep_empty_params=False):
        """
        Fetches a group from your organization.
        Args:
            group_id {str}
        Returns:
            Group
        """
        http_method = "get".upper()
        api_url = format_url(f"""
            {self._base_url}
            /api/v1/groups/{groupId}
            """)

        body = {}
        headers = {}
        form = {}

        request, error = await self._request_executor.create_request(
            http_method,
            api_url,
            body,
            headers,
            form,
            keep_empty_params=keep_empty_params)

        if error:
            return (None, None, error)

        response, error = await self._request_executor\
            .execute(request, Group)

        if error:
            return (None, response, error)

        try:
            result = Group(self.form_response_body(response.get_body()))
        except Exception as error:
            return (None, response, error)
        return (result, response, None)