# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from .sso import (
    SSOResource,
    AsyncSSOResource,
    SSOResourceWithRawResponse,
    AsyncSSOResourceWithRawResponse,
    SSOResourceWithStreamingResponse,
    AsyncSSOResourceWithStreamingResponse,
)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from .oauth_scopes import (
    OAuthScopesResource,
    AsyncOAuthScopesResource,
    OAuthScopesResourceWithRawResponse,
    AsyncOAuthScopesResourceWithRawResponse,
    OAuthScopesResourceWithStreamingResponse,
    AsyncOAuthScopesResourceWithStreamingResponse,
)
from .oauth_clients import (
    OAuthClientsResource,
    AsyncOAuthClientsResource,
    OAuthClientsResourceWithRawResponse,
    AsyncOAuthClientsResourceWithRawResponse,
    OAuthClientsResourceWithStreamingResponse,
    AsyncOAuthClientsResourceWithStreamingResponse,
)
from .resource_groups import (
    ResourceGroupsResource,
    AsyncResourceGroupsResource,
    ResourceGroupsResourceWithRawResponse,
    AsyncResourceGroupsResourceWithRawResponse,
    ResourceGroupsResourceWithStreamingResponse,
    AsyncResourceGroupsResourceWithStreamingResponse,
)
from .permission_groups import (
    PermissionGroupsResource,
    AsyncPermissionGroupsResource,
    PermissionGroupsResourceWithRawResponse,
    AsyncPermissionGroupsResourceWithRawResponse,
    PermissionGroupsResourceWithStreamingResponse,
    AsyncPermissionGroupsResourceWithStreamingResponse,
)
from .user_groups.user_groups import (
    UserGroupsResource,
    AsyncUserGroupsResource,
    UserGroupsResourceWithRawResponse,
    AsyncUserGroupsResourceWithRawResponse,
    UserGroupsResourceWithStreamingResponse,
    AsyncUserGroupsResourceWithStreamingResponse,
)

__all__ = ["IAMResource", "AsyncIAMResource"]


class IAMResource(SyncAPIResource):
    @cached_property
    def permission_groups(self) -> PermissionGroupsResource:
        return PermissionGroupsResource(self._client)

    @cached_property
    def resource_groups(self) -> ResourceGroupsResource:
        return ResourceGroupsResource(self._client)

    @cached_property
    def user_groups(self) -> UserGroupsResource:
        return UserGroupsResource(self._client)

    @cached_property
    def sso(self) -> SSOResource:
        return SSOResource(self._client)

    @cached_property
    def oauth_clients(self) -> OAuthClientsResource:
        return OAuthClientsResource(self._client)

    @cached_property
    def oauth_scopes(self) -> OAuthScopesResource:
        return OAuthScopesResource(self._client)

    @cached_property
    def with_raw_response(self) -> IAMResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
        """
        return IAMResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> IAMResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
        """
        return IAMResourceWithStreamingResponse(self)


class AsyncIAMResource(AsyncAPIResource):
    @cached_property
    def permission_groups(self) -> AsyncPermissionGroupsResource:
        return AsyncPermissionGroupsResource(self._client)

    @cached_property
    def resource_groups(self) -> AsyncResourceGroupsResource:
        return AsyncResourceGroupsResource(self._client)

    @cached_property
    def user_groups(self) -> AsyncUserGroupsResource:
        return AsyncUserGroupsResource(self._client)

    @cached_property
    def sso(self) -> AsyncSSOResource:
        return AsyncSSOResource(self._client)

    @cached_property
    def oauth_clients(self) -> AsyncOAuthClientsResource:
        return AsyncOAuthClientsResource(self._client)

    @cached_property
    def oauth_scopes(self) -> AsyncOAuthScopesResource:
        return AsyncOAuthScopesResource(self._client)

    @cached_property
    def with_raw_response(self) -> AsyncIAMResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
        """
        return AsyncIAMResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncIAMResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
        """
        return AsyncIAMResourceWithStreamingResponse(self)


class IAMResourceWithRawResponse:
    def __init__(self, iam: IAMResource) -> None:
        self._iam = iam

    @cached_property
    def permission_groups(self) -> PermissionGroupsResourceWithRawResponse:
        return PermissionGroupsResourceWithRawResponse(self._iam.permission_groups)

    @cached_property
    def resource_groups(self) -> ResourceGroupsResourceWithRawResponse:
        return ResourceGroupsResourceWithRawResponse(self._iam.resource_groups)

    @cached_property
    def user_groups(self) -> UserGroupsResourceWithRawResponse:
        return UserGroupsResourceWithRawResponse(self._iam.user_groups)

    @cached_property
    def sso(self) -> SSOResourceWithRawResponse:
        return SSOResourceWithRawResponse(self._iam.sso)

    @cached_property
    def oauth_clients(self) -> OAuthClientsResourceWithRawResponse:
        return OAuthClientsResourceWithRawResponse(self._iam.oauth_clients)

    @cached_property
    def oauth_scopes(self) -> OAuthScopesResourceWithRawResponse:
        return OAuthScopesResourceWithRawResponse(self._iam.oauth_scopes)


class AsyncIAMResourceWithRawResponse:
    def __init__(self, iam: AsyncIAMResource) -> None:
        self._iam = iam

    @cached_property
    def permission_groups(self) -> AsyncPermissionGroupsResourceWithRawResponse:
        return AsyncPermissionGroupsResourceWithRawResponse(self._iam.permission_groups)

    @cached_property
    def resource_groups(self) -> AsyncResourceGroupsResourceWithRawResponse:
        return AsyncResourceGroupsResourceWithRawResponse(self._iam.resource_groups)

    @cached_property
    def user_groups(self) -> AsyncUserGroupsResourceWithRawResponse:
        return AsyncUserGroupsResourceWithRawResponse(self._iam.user_groups)

    @cached_property
    def sso(self) -> AsyncSSOResourceWithRawResponse:
        return AsyncSSOResourceWithRawResponse(self._iam.sso)

    @cached_property
    def oauth_clients(self) -> AsyncOAuthClientsResourceWithRawResponse:
        return AsyncOAuthClientsResourceWithRawResponse(self._iam.oauth_clients)

    @cached_property
    def oauth_scopes(self) -> AsyncOAuthScopesResourceWithRawResponse:
        return AsyncOAuthScopesResourceWithRawResponse(self._iam.oauth_scopes)


class IAMResourceWithStreamingResponse:
    def __init__(self, iam: IAMResource) -> None:
        self._iam = iam

    @cached_property
    def permission_groups(self) -> PermissionGroupsResourceWithStreamingResponse:
        return PermissionGroupsResourceWithStreamingResponse(self._iam.permission_groups)

    @cached_property
    def resource_groups(self) -> ResourceGroupsResourceWithStreamingResponse:
        return ResourceGroupsResourceWithStreamingResponse(self._iam.resource_groups)

    @cached_property
    def user_groups(self) -> UserGroupsResourceWithStreamingResponse:
        return UserGroupsResourceWithStreamingResponse(self._iam.user_groups)

    @cached_property
    def sso(self) -> SSOResourceWithStreamingResponse:
        return SSOResourceWithStreamingResponse(self._iam.sso)

    @cached_property
    def oauth_clients(self) -> OAuthClientsResourceWithStreamingResponse:
        return OAuthClientsResourceWithStreamingResponse(self._iam.oauth_clients)

    @cached_property
    def oauth_scopes(self) -> OAuthScopesResourceWithStreamingResponse:
        return OAuthScopesResourceWithStreamingResponse(self._iam.oauth_scopes)


class AsyncIAMResourceWithStreamingResponse:
    def __init__(self, iam: AsyncIAMResource) -> None:
        self._iam = iam

    @cached_property
    def permission_groups(self) -> AsyncPermissionGroupsResourceWithStreamingResponse:
        return AsyncPermissionGroupsResourceWithStreamingResponse(self._iam.permission_groups)

    @cached_property
    def resource_groups(self) -> AsyncResourceGroupsResourceWithStreamingResponse:
        return AsyncResourceGroupsResourceWithStreamingResponse(self._iam.resource_groups)

    @cached_property
    def user_groups(self) -> AsyncUserGroupsResourceWithStreamingResponse:
        return AsyncUserGroupsResourceWithStreamingResponse(self._iam.user_groups)

    @cached_property
    def sso(self) -> AsyncSSOResourceWithStreamingResponse:
        return AsyncSSOResourceWithStreamingResponse(self._iam.sso)

    @cached_property
    def oauth_clients(self) -> AsyncOAuthClientsResourceWithStreamingResponse:
        return AsyncOAuthClientsResourceWithStreamingResponse(self._iam.oauth_clients)

    @cached_property
    def oauth_scopes(self) -> AsyncOAuthScopesResourceWithStreamingResponse:
        return AsyncOAuthScopesResourceWithStreamingResponse(self._iam.oauth_scopes)
