# This file is auto-generated by oagen. Do not edit.

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Dict, Optional

if TYPE_CHECKING:
    from .._client import AsyncWorkOSClient, WorkOSClient

from .._types import RequestOptions
from workos.common.models.organization_domain import OrganizationDomain


class OrganizationDomains:
    """Organization Domains API resources."""

    def __init__(self, client: "WorkOSClient") -> None:
        self._client = client

    def create_organization_domain(
        self,
        *,
        domain: str,
        organization_id: str,
        request_options: Optional[RequestOptions] = None,
    ) -> OrganizationDomain:
        """Create an Organization Domain

        Creates a new Organization Domain.

        Args:
            domain: The domain to add to the organization.
            organization_id: The ID of the organization to add the domain to.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Returns:
            OrganizationDomain

        Raises:
            ConflictError: If a conflict occurs (409).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        body: Dict[str, Any] = {
            "domain": domain,
            "organization_id": organization_id,
        }
        return self._client.request(
            method="post",
            path=("organization_domains",),
            body=body,
            model=OrganizationDomain,
            request_options=request_options,
        )

    def get_organization_domain(
        self,
        id: str,
        *,
        request_options: Optional[RequestOptions] = None,
    ) -> OrganizationDomain:
        """Get an Organization Domain

        Get the details of an existing organization domain.

        Args:
            id: Unique identifier of the organization domain.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Returns:
            OrganizationDomain

        Raises:
            NotFoundError: If the resource is not found (404).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        return self._client.request(
            method="get",
            path=("organization_domains", str(id)),
            model=OrganizationDomain,
            request_options=request_options,
        )

    def delete_organization_domain(
        self,
        id: str,
        *,
        request_options: Optional[RequestOptions] = None,
    ) -> None:
        """Delete an Organization Domain

        Permanently deletes an organization domain. It cannot be undone.

        Args:
            id: Unique identifier of the organization domain.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Raises:
            NotFoundError: If the resource is not found (404).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        self._client.request(
            method="delete",
            path=("organization_domains", str(id)),
            request_options=request_options,
        )

    def verify_organization_domain(
        self,
        id: str,
        *,
        request_options: Optional[RequestOptions] = None,
    ) -> OrganizationDomain:
        """Verify an Organization Domain

        Initiates verification process for an Organization Domain.

        Args:
            id: Unique identifier of the organization domain.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Returns:
            OrganizationDomain

        Raises:
            BadRequestError: If the request is malformed (400).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        return self._client.request(
            method="post",
            path=("organization_domains", str(id), "verify"),
            model=OrganizationDomain,
            request_options=request_options,
        )


class AsyncOrganizationDomains:
    """Organization Domains API resources (async)."""

    def __init__(self, client: "AsyncWorkOSClient") -> None:
        self._client = client

    async def create_organization_domain(
        self,
        *,
        domain: str,
        organization_id: str,
        request_options: Optional[RequestOptions] = None,
    ) -> OrganizationDomain:
        """Create an Organization Domain

        Creates a new Organization Domain.

        Args:
            domain: The domain to add to the organization.
            organization_id: The ID of the organization to add the domain to.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Returns:
            OrganizationDomain

        Raises:
            ConflictError: If a conflict occurs (409).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        body: Dict[str, Any] = {
            "domain": domain,
            "organization_id": organization_id,
        }
        return await self._client.request(
            method="post",
            path=("organization_domains",),
            body=body,
            model=OrganizationDomain,
            request_options=request_options,
        )

    async def get_organization_domain(
        self,
        id: str,
        *,
        request_options: Optional[RequestOptions] = None,
    ) -> OrganizationDomain:
        """Get an Organization Domain

        Get the details of an existing organization domain.

        Args:
            id: Unique identifier of the organization domain.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Returns:
            OrganizationDomain

        Raises:
            NotFoundError: If the resource is not found (404).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        return await self._client.request(
            method="get",
            path=("organization_domains", str(id)),
            model=OrganizationDomain,
            request_options=request_options,
        )

    async def delete_organization_domain(
        self,
        id: str,
        *,
        request_options: Optional[RequestOptions] = None,
    ) -> None:
        """Delete an Organization Domain

        Permanently deletes an organization domain. It cannot be undone.

        Args:
            id: Unique identifier of the organization domain.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Raises:
            NotFoundError: If the resource is not found (404).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        await self._client.request(
            method="delete",
            path=("organization_domains", str(id)),
            request_options=request_options,
        )

    async def verify_organization_domain(
        self,
        id: str,
        *,
        request_options: Optional[RequestOptions] = None,
    ) -> OrganizationDomain:
        """Verify an Organization Domain

        Initiates verification process for an Organization Domain.

        Args:
            id: Unique identifier of the organization domain.
            request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.

        Returns:
            OrganizationDomain

        Raises:
            BadRequestError: If the request is malformed (400).
            AuthenticationError: If the API key is invalid (401).
            RateLimitExceededError: If rate limited (429).
            ServerError: If the server returns a 5xx error.
        """
        return await self._client.request(
            method="post",
            path=("organization_domains", str(id), "verify"),
            model=OrganizationDomain,
            request_options=request_options,
        )
