#
# # Copyright © 2023 Peak AI Limited. or its affiliates. All Rights Reserved.
# #
# # Licensed under the Apache License, Version 2.0 (the "License"). You
# # may not use this file except in compliance with the License. A copy of
# # the License is located at:
# #
# # https://github.com/PeakBI/peak-sdk/blob/main/LICENSE
# #
# # or in the "license" file accompanying this file. This file is
# # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# # ANY KIND, either express or implied. See the License for the specific
# # language governing permissions and limitations under the License.
# #
# # This file is part of the peak-sdk.
# # see (https://github.com/PeakBI/peak-sdk)
# #
# # You should have received a copy of the APACHE LICENSE, VERSION 2.0
# # along with this program. If not, see <https://apache.org/licenses/LICENSE-2.0>
#
"""Blocks client module."""
from __future__ import annotations

import json
from typing import Any, Dict, Iterator, List, Literal, Optional, overload

from peak.base_client import BaseClient
from peak.constants import ArtifactInfo, ContentType, HttpMethods
from peak.session import Session


class Block(BaseClient):
    """Client class for interacting with Blocks."""

    SPECS_BASE_ENDPOINT = "v1/blocks/specs"
    DEPLOYMENTS_BASE_ENDPOINT = "v1/blocks/deployments"

    @overload
    def list_specs(
        self,
        status: Optional[List[str]] = None,
        featured: Optional[bool] = None,
        name: Optional[str] = None,
        title: Optional[str] = None,
        sort: Optional[List[str]] = None,
        scope: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: Literal[False],
    ) -> Dict[str, Any]:
        ...

    @overload
    def list_specs(
        self,
        status: Optional[List[str]] = None,
        featured: Optional[bool] = None,
        name: Optional[str] = None,
        title: Optional[str] = None,
        sort: Optional[List[str]] = None,
        scope: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: Literal[True] = True,
    ) -> Iterator[Dict[str, Any]]:
        ...

    def list_specs(
        self,
        status: Optional[List[str]] = None,
        featured: Optional[bool] = None,
        name: Optional[str] = None,
        title: Optional[str] = None,
        sort: Optional[List[str]] = None,
        scope: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: bool = True,
    ) -> Iterator[Dict[str, Any]] | Dict[str, Any]:
        """Lists all published Block specs ordered by creation date. Returns info for the latest release for each spec.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs>`__

        Args:
            status (List[str] | None): List of statuses to filter specs.
            featured (bool | None): Whether to only return featured specs.
            name (str | None): Only return specs whose names begins with the query string.
            title (str | None): Only return specs whose title begins with the query string.
            sort (List[str] | None): List of fields with desired ordering in the format `[<field>:<order>, ...]`,
                where `order` is one of `['asc', 'desc']` and field is an ordered parameter within the response,
                defaults to `[]`. Valid fields are `createdAt`, `createdBy`, `name` and `title`.
            scope (List[str] | None): List of scopes to only return specs of those scopes. Valid values are `private`, `public` and `shared`.
            page_size (int | None): Number of specs to include per page.
            page_number (int | None): The page number to retrieve. Only used when `return_iterator` is False.
            return_iterator (bool): Whether to return an iterator object or list of specs for a specified page number, defaults to True.

        Returns:
            Iterator[Dict[str, Any]] | Dict[str, Any]: an iterator object which returns an element per iteration, until there are no more elements to return.
            If `return_iterator` is set to False, a dictionary containing the list and pagination details is returned instead.

            Set `return_iterator` to True if you want automatic client-side pagination, or False if you want server-side pagination.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
            StopIteration: There are no more pages to list.
        """
        method, endpoint = HttpMethods.GET, f"{self.SPECS_BASE_ENDPOINT}/"
        params: Dict[str, Any] = {
            "status": status,
            "featured": featured,
            "name": name,
            "title": title,
            "sort": sort,
            "scope": scope,
            "pageSize": page_size,
        }

        if return_iterator:
            return self.session.create_generator_request(
                endpoint,
                method,
                content_type=ContentType.APPLICATION_JSON,
                response_key="specs",
                params=params,
                subdomain="press",
            )

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            params={**params, "pageNumber": page_number},
            subdomain="press",
        )

    def create_spec(
        self,
        body: Dict[str, Any],
        artifact: Optional[ArtifactInfo] = None,
        featured: Optional[bool] = None,
        scope: Optional[str] = None,
        tenants: Optional[List[str]] = None,
    ) -> Dict[str, str]:
        """Create a new Block spec.

        For each Block kind, all Specs must have unique names within a tenant.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/post_v1_blocks_specs>`__

        Args:
            body (Dict[str, Any]): Dictionary containing Block spec metadata and configuration.
            artifact (ArtifactInfo | None):    Mapping of artifact attributes that specifies how the artifact will be generated,
                                        it accepts two keys `path`, which is required and `ignore_files` which is optional, and defaults to `.dockerignore`, it is strongly advised that users use `ignore_files` when generating artifacts to avoid copying any extra files in artifact.
                                        It is not required if an existing image and version is used for creating the spec.
            featured (bool | None): Whether to feature this spec. By default it is False.
            scope (str | None): Specify weather tenants can discover and deploy this spec.
                `private` restricts the spec to this tenant alone, `public` makes it available on all tenants
                and `shared` allows specifying what set of tenants can access and use this spec.
                By default it is `private`.
            tenants (List[str] | None): Given a shared scope, specify what other tenants can discover and deploy this spec.

        Returns:
            Dict[str, str]: Id of the created block spec.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            PayloadTooLargeException: The given artifact size exceeds maximum limit.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.POST, f"{self.SPECS_BASE_ENDPOINT}/"

        body = {
            "spec": json.dumps(body),
            "featured": json.dumps(featured),
            "scope": scope,
        }

        if tenants:
            body["tenants"] = json.dumps(tenants)

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.MULTIPART_FORM_DATA,
            body=body,
            path=artifact["path"] if artifact is not None else None,
            ignore_files=artifact.get("ignore_files") if artifact is not None else None,
            subdomain="press",
        )

    def describe_spec(
        self,
        spec_id: str,
    ) -> Dict[str, Any]:
        """Describes an existing Block spec and also provides details of the latest release.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId_>`__

        Args:
            spec_id (str): The ID of the workflow spec to retrieve.

        Returns:
            Dict[str, Any]: Dictionary containing the details of the spec.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given workflow spec does not exist.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.GET, f"{self.SPECS_BASE_ENDPOINT}/{spec_id}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            subdomain="press",
        )

    def update_spec_metadata(self, spec_id: str, body: Dict[str, Any]) -> Dict[None, None]:
        """Update the metadata and discoverability of a Block Spec.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/patch_v1_blocks_specs__specId_>`__

        Args:
            spec_id (str): ID of the spec to update
            body (Dict[str, Any]): Dictionary containing the new spec metadata

        Returns:
            dict: Dictionary containing the details of the updated spec.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given Workflow spec does not exist.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.PATCH, f"{self.SPECS_BASE_ENDPOINT}/{spec_id}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            body=body,
            subdomain="press",
        )

    def delete_spec(
        self,
        spec_id: str,
    ) -> Dict[None, None]:
        """Delete a Block Spec and all it's associated releases.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/delete_v1_blocks_specs__specId_>`__

        Args:
            spec_id (str): The ID of the Block spec to delete.

        Returns:
            dict: Empty dict object.

        Raises:
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given Block spec does not exist.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: the server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.DELETE, f"{self.SPECS_BASE_ENDPOINT}/{spec_id}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            subdomain="press",
        )

    def create_spec_release(
        self,
        spec_id: str,
        body: Dict[str, Any],
        artifact: Optional[ArtifactInfo] = None,
    ) -> Dict[str, str]:
        """Publish a new release to an existing Block spec.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/post_v1_blocks_specs__specId__releases>`__

        Args:
            spec_id (str): Id of the spec in which new release will be created.
            body (Dict[str, Any]): Dictionary containing updated release and config in the expected format.
            artifact (ArtifactInfo | None):    Mapping of artifact attributes that specifies how the artifact will be generated,
                                        it accepts two keys `path`, which is required and `ignore_files` which is optional, and defaults to `.dockerignore`, it is strongly advised that users use `ignore_files` when generating artifacts to avoid copying any extra files in artifact.
                                        It is not required if an existing image and version is used for creating the spec.

        Returns:
            Dict[str, str]: Dictionary containing spec id and release version

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            PayloadTooLargeException: The given artifact size exceeds maximum limit.
            NotFoundException: The given app spec does not exist.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: the server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.POST, f"{self.SPECS_BASE_ENDPOINT}/{spec_id}/releases"

        body = {
            "spec": json.dumps(body),
        }

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.MULTIPART_FORM_DATA,
            body=body,
            path=artifact["path"] if artifact is not None else None,
            ignore_files=artifact.get("ignore_files") if artifact is not None else None,
            subdomain="press",
        )

    @overload
    def list_spec_releases(
        self,
        spec_id: str,
        sort: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: Literal[False],
    ) -> Dict[str, Any]:
        ...

    @overload
    def list_spec_releases(
        self,
        spec_id: str,
        sort: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: Literal[True] = True,
    ) -> Iterator[Dict[str, Any]]:
        ...

    def list_spec_releases(
        self,
        spec_id: str,
        sort: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: bool = True,
    ) -> Iterator[Dict[str, Any]] | Dict[str, Any]:
        """Get all releases of a Block spec (ordered by most recently created to oldest).

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId__releases>`__

        Args:
            spec_id (str): The ID of the Block spec to retrieve.
            sort (List[str] | None): List of fields with desired ordering in the format `[<field>:<order>, ...]`,
                where `order` is one of `['asc', 'desc']` and field is an ordered parameter within the response.
                Valid fields are `createdAt` and `createdBy`.
            page_size (int | None): Number of specs to include per page.
            page_number (int | None): The page number to retrieve. Only used when `return_iterator` is False.
            return_iterator (bool): Whether to return an iterator object or list of releases for a specified page number, defaults to True.

        Returns:
            Iterator[Dict[str, Any]] | Dict[str, Any]: an iterator object which returns an element per iteration, until there are no more elements to return.
            If `return_iterator` is set to False, a dictionary containing the list and pagination details is returned instead.

            Set `return_iterator` to True if you want automatic client-side pagination, or False if you want server-side pagination.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given Block spec does not exist.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
            StopIteration: There are no more pages to list.
        """
        method, endpoint = HttpMethods.GET, f"{self.SPECS_BASE_ENDPOINT}/{spec_id}/releases"
        params: Dict[str, Any] = {
            "pageSize": page_size,
            "sort": sort,
        }

        if return_iterator:
            return self.session.create_generator_request(
                endpoint,
                method,
                content_type=ContentType.APPLICATION_JSON,
                response_key="releases",
                params=params,
                subdomain="press",
            )

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            params={**params, "pageNumber": page_number},
            subdomain="press",
        )

    def describe_spec_release(
        self,
        spec_id: str,
        version: str,
    ) -> Dict[str, Any]:
        """Describe an existing spec release.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId__releases__release_>`__

        Args:
            spec_id (str): The ID of the block spec to retrieve.
            version (str): The release version of spec to retrieve in valid semantic versioning format.

        Returns:
            Dict[str, Any]: Dictionary containing the details of the spec.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given block spec does not exist.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.GET, f"{self.SPECS_BASE_ENDPOINT}/{spec_id}/releases/{version}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            subdomain="press",
        )

    def create_deployment(self, body: Dict[str, str]) -> Dict[str, str]:
        """Creates a new deployment from Block spec.

        Uses the latest spec release if release version is not provided.
        For each Block kind, all Deployments must have unique names within a tenant.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/post_v1_blocks_deployments>`__

        Args:
            body (Dict[str, str]): Dictionary containing deployment metadata, spec ID, release version (optional, defaults to latest spec release) and revision info.

        Returns:
            Dict[str, str]: ID of the created Block deployment

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given workflow spec release does not exist.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.POST, f"{self.DEPLOYMENTS_BASE_ENDPOINT}/"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            body=body,
            subdomain="press",
        )

    @overload
    def list_deployments(
        self,
        status: Optional[List[str]] = None,
        name: Optional[str] = None,
        title: Optional[str] = None,
        sort: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: Literal[False],
    ) -> Dict[str, Any]:
        ...

    @overload
    def list_deployments(
        self,
        status: Optional[List[str]] = None,
        name: Optional[str] = None,
        title: Optional[str] = None,
        sort: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: Literal[True] = True,
    ) -> Iterator[Dict[str, Any]]:
        ...

    def list_deployments(
        self,
        status: Optional[List[str]] = None,
        name: Optional[str] = None,
        title: Optional[str] = None,
        sort: Optional[List[str]] = None,
        page_size: Optional[int] = None,
        page_number: Optional[int] = None,
        *,
        return_iterator: bool = True,
    ) -> Iterator[Dict[str, Any]] | Dict[str, Any]:
        """Lists Block deployments ordered by creation date.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/get_v1_blocks_deployments>`__

        Args:
            status (List[str] | None): List of statuses to filter deployments.
            name (str | None): Only return deployments whose names begins with the query string.
            title (str | None): Only return deployments whose title begins with the query string.
            sort (List[str] | None): List of fields with desired ordering in the format `[<field>:<order>, ...]`,
                where `order` is one of `['asc', 'desc']` and field is an ordered parameter within the response.
                Valid fields are `createdAt`, `createdBy`, `name` and `title`.
            page_size (int | None): Number of deployments to include per page.
            page_number (int | None): The page number to retrieve. Only used when `return_iterator` is False.
            return_iterator (bool): Whether to return an iterator object or list of deployments for a specified page number, defaults to True.

        Returns:
            Iterator[Dict[str, Any]] | Dict[str, Any]: an iterator object which returns an element per iteration, until there are no more elements to return.
            If `return_iterator` is set to False, a dictionary containing the list and pagination details is returned instead.

            Set `return_iterator` to True if you want automatic client-side pagination, or False if you want server-side pagination.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
            StopIteration: There are no more pages to list.
        """
        method, endpoint = HttpMethods.GET, f"{self.DEPLOYMENTS_BASE_ENDPOINT}/"

        params: Dict[str, Any] = {
            "status": status,
            "name": name,
            "title": title,
            "sort": sort,
            "pageSize": page_size,
        }

        if return_iterator:
            return self.session.create_generator_request(
                endpoint,
                method,
                content_type=ContentType.APPLICATION_JSON,
                response_key="deployments",
                params=params,
                subdomain="press",
            )

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            params={**params, "pageNumber": page_number},
            subdomain="press",
        )

    def describe_deployment(self, deployment_id: str) -> dict[str, Any]:
        """Describes an existing Block deployment, also provides details of the latest revision.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/get_v1_blocks_deployments__deploymentId_>`__

        Args:
            deployment_id (str): The ID of the Block deployment to retrieve.

        Returns:
            Dict[str, Any]: Dictionary containing the details of the deployment.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given Block deployment does not exist.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.GET, f"{self.DEPLOYMENTS_BASE_ENDPOINT}/{deployment_id}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            subdomain="press",
        )

    def update_deployment_metadata(
        self,
        deployment_id: str,
        body: Dict[str, Any],
    ) -> Dict[None, None]:
        """Update the metadata of the Block deployment.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/patch_v1_blocks_deployments__deploymentId_>`__

        Args:
            deployment_id (str): ID of the Block deployment to update.
            body (Dict[str, Any]): Dictionary of the new deployment metadata.

        Returns:
            dict: Details of the updated deployment.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given Workflow spec does not exist.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: The server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.PATCH, f"{self.DEPLOYMENTS_BASE_ENDPOINT}/{deployment_id}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            body=body,
            subdomain="press",
        )

    def delete_deployment(self, deployment_id: str) -> Dict[None, None]:
        """Deletes the Block deployment.

        REFERENCE:
            🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/delete_v1_blocks_deployments__deploymentId_>`__

        Args:
            deployment_id (str): The ID of the Block deployment to delete.

        Returns:
            dict: Empty dict object.

        Raises:
            BadRequestException: The given parameters are invalid.
            UnauthorizedException: The credentials are invalid.
            ForbiddenException: The user does not have permission to perform the operation.
            NotFoundException: The given Block deployment does not exist.
            UnprocessableEntityException: The server was unable to process the request.
            InternalServerErrorException: the server encountered an unexpected condition that
                prevented it from fulfilling the request.
        """
        method, endpoint = HttpMethods.DELETE, f"{self.DEPLOYMENTS_BASE_ENDPOINT}/{deployment_id}"

        return self.session.create_request(  # type: ignore[no-any-return]
            endpoint,
            method,
            content_type=ContentType.APPLICATION_JSON,
            subdomain="press",
        )


def get_client(session: Optional[Session] = None) -> Block:
    """Returns a Workflow Block client.

    Args:
        session (Optional[Session]): A Session Object. If no session is provided, a default session is used.

    Returns:
        Block: the Workflow Block client object
    """
    return Block(session)


__all__: List[str] = ["get_client"]
