Skip to content

GCP

Validated types for Google Cloud Platform resource identifiers.

GCP cloud resource types.

Modules:

  • compute

    GCP compute types.

  • containers

    GCP container types.

  • database

    GCP database types.

  • identity

    GCP identity types.

  • messaging

    GCP messaging types.

  • region

    GCP region and zone types.

  • security

    GCP security types.

  • storage

    GCP storage types.

Classes:

Attributes:

  • BigQueryDatasetId

    A GCP BigQuery dataset ID (e.g. my_dataset).

  • BillingAccountId

    A GCP billing account ID (e.g. 01A2B3-C4D5E6-F7G8H9).

  • CloudFunctionName

    A GCP Cloud Function name (1-49 lowercase chars) (e.g. my-function).

  • CloudRunServiceName

    A GCP Cloud Run service name (1-49 lowercase chars) (e.g. my-service).

  • CloudSqlInstanceId

    A GCP Cloud SQL instance ID (max 84 chars) (e.g. my-sql-instance).

  • ComputeResourceName

    A GCP Compute Engine resource name (1-63 lowercase chars) (e.g. my-vm-instance).

  • GcsBucketName

    A GCP Cloud Storage bucket name (e.g. my-bucket).

  • OrganizationId

    A GCP organization ID (e.g. 123456789012).

  • ProjectId

    A GCP project ID (6-30 lowercase chars) (e.g. my-project-123).

  • ProjectNumber

    A GCP project number (e.g. 123456789012).

  • SpannerDatabaseId

    A GCP Spanner database ID (2-30 chars) (e.g. my-spanner-db).

  • SpannerInstanceId

    A GCP Spanner instance ID (2-64 chars) (e.g. my-spanner-instance).

BigQueryDatasetId module-attribute

BigQueryDatasetId = Annotated[str, AfterValidator(_validate_bigquery_dataset_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP BigQuery dataset ID.', 'examples': ['my_dataset'], 'title': 'BigQueryDatasetId'})]

A GCP BigQuery dataset ID (e.g. my_dataset).

BillingAccountId module-attribute

BillingAccountId = Annotated[str, AfterValidator(_validate_billing_account_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP billing account ID.', 'examples': ['01A2B3-C4D5E6-F7G8H9'], 'title': 'BillingAccountId'})]

A GCP billing account ID (e.g. 01A2B3-C4D5E6-F7G8H9).

CloudFunctionName module-attribute

CloudFunctionName = Annotated[str, AfterValidator(_validate_cloud_function_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Cloud Function name (1-49 lowercase chars).', 'examples': ['my-function'], 'title': 'CloudFunctionName'})]

A GCP Cloud Function name (1-49 lowercase chars) (e.g. my-function).

CloudRunServiceName module-attribute

CloudRunServiceName = Annotated[str, AfterValidator(_validate_cloud_run_service_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Cloud Run service name (1-49 lowercase chars).', 'examples': ['my-service'], 'title': 'CloudRunServiceName'})]

A GCP Cloud Run service name (1-49 lowercase chars) (e.g. my-service).

CloudSqlInstanceId module-attribute

CloudSqlInstanceId = Annotated[str, AfterValidator(_validate_cloud_sql_instance_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Cloud SQL instance ID (max 84 chars).', 'examples': ['my-sql-instance'], 'title': 'CloudSqlInstanceId'})]

A GCP Cloud SQL instance ID (max 84 chars) (e.g. my-sql-instance).

ComputeResourceName module-attribute

ComputeResourceName = Annotated[str, AfterValidator(_validate_compute_resource_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Compute Engine resource name (1-63 lowercase chars).', 'examples': ['my-vm-instance'], 'title': 'ComputeResourceName'})]

A GCP Compute Engine resource name (1-63 lowercase chars) (e.g. my-vm-instance).

GcsBucketName module-attribute

GcsBucketName = Annotated[str, AfterValidator(_validate_gcs_bucket_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Cloud Storage bucket name.', 'examples': ['my-bucket'], 'title': 'GcsBucketName', 'minLength': 3, 'maxLength': 63})]

A GCP Cloud Storage bucket name (e.g. my-bucket).

OrganizationId module-attribute

OrganizationId = Annotated[str, AfterValidator(_validate_organization_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP organization ID.', 'examples': ['123456789012'], 'title': 'OrganizationId'})]

A GCP organization ID (e.g. 123456789012).

ProjectId module-attribute

ProjectId = Annotated[str, AfterValidator(_validate_project_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP project ID (6-30 lowercase chars).', 'examples': ['my-project-123'], 'title': 'ProjectId'})]

A GCP project ID (6-30 lowercase chars) (e.g. my-project-123).

ProjectNumber module-attribute

ProjectNumber = Annotated[str, AfterValidator(_validate_project_number), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP project number.', 'examples': ['123456789012'], 'title': 'ProjectNumber'})]

A GCP project number (e.g. 123456789012).

SpannerDatabaseId module-attribute

SpannerDatabaseId = Annotated[str, AfterValidator(_validate_spanner_database_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Spanner database ID (2-30 chars).', 'examples': ['my-spanner-db'], 'title': 'SpannerDatabaseId', 'minLength': 2, 'maxLength': 30})]

A GCP Spanner database ID (2-30 chars) (e.g. my-spanner-db).

SpannerInstanceId module-attribute

SpannerInstanceId = Annotated[str, AfterValidator(_validate_spanner_instance_id), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A GCP Spanner instance ID (2-64 chars).', 'examples': ['my-spanner-instance'], 'title': 'SpannerInstanceId', 'minLength': 2, 'maxLength': 64})]

A GCP Spanner instance ID (2-64 chars) (e.g. my-spanner-instance).

ArtifactRegistryImageUri

Bases: str

A validated GCP Artifact Registry image URI.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for ArtifactRegistryImageUri.

Source code in src/pydantypes/cloud/gcp/containers.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for ArtifactRegistryImageUri."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for ArtifactRegistryImageUri.

Source code in src/pydantypes/cloud/gcp/containers.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for ArtifactRegistryImageUri."""
    return {
        "type": "string",
        "format": "gcp-artifact-registry-image-uri",
        "pattern": cls._pattern.pattern,
        "description": "A GCP Artifact Registry image URI.",
        "examples": ["us-docker.pkg.dev/my-project/my-repo/my-image:latest"],
        "title": "ArtifactRegistryImageUri",
    }

__new__

__new__(value: str) -> ArtifactRegistryImageUri

Create and validate a new ArtifactRegistryImageUri instance.

Source code in src/pydantypes/cloud/gcp/containers.py
def __new__(cls, value: str) -> ArtifactRegistryImageUri:
    """Create and validate a new ArtifactRegistryImageUri instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_artifact_registry_image_uri",
            "Invalid GCP Artifact Registry image URI: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.location = m.group(1)
    instance.project_id = m.group(2)
    instance.repository = m.group(3)
    instance.image = m.group(4)
    instance.tag = m.group(5) or ""
    instance.digest = m.group(6) or ""
    return instance

BigQueryTableId

Bases: str

A validated BigQuery fully-qualified table ID.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for BigQueryTableId.

Source code in src/pydantypes/cloud/gcp/database.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for BigQueryTableId."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for BigQueryTableId.

Source code in src/pydantypes/cloud/gcp/database.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for BigQueryTableId."""
    return {
        "type": "string",
        "format": "gcp-bigquery-table-id",
        "pattern": cls._pattern.pattern,
        "description": (
            "A fully-qualified BigQuery table ID"
            " (project.dataset.table or project:dataset.table)."
        ),
        "examples": ["my-project.my_dataset.my_table"],
        "title": "BigQueryTableId",
    }

__new__

__new__(value: str) -> BigQueryTableId

Create and validate a new BigQueryTableId instance.

Source code in src/pydantypes/cloud/gcp/database.py
def __new__(cls, value: str) -> BigQueryTableId:
    """Create and validate a new BigQueryTableId instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_bigquery_table_id",
            "Invalid BigQuery table ID: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.project_id = m.group(1)
    instance.dataset_id = m.group(2)
    instance.table_id = m.group(3)
    return instance

GcsUri

Bases: CloudStorageUri

A validated Google Cloud Storage URI (gs://bucket/key).

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for GcsUri.

Source code in src/pydantypes/cloud/gcp/storage.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for GcsUri."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for GcsUri.

Source code in src/pydantypes/cloud/gcp/storage.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for GcsUri."""
    return {
        "type": "string",
        "format": "gcs-uri",
        "pattern": cls._pattern.pattern,
        "description": "A Google Cloud Storage URI (gs://bucket/key).",
        "examples": ["gs://my-bucket/path/to/file.csv"],
        "title": "GcsUri",
    }

__new__

__new__(value: str) -> GcsUri

Create and validate a new GcsUri instance.

Source code in src/pydantypes/cloud/gcp/storage.py
def __new__(cls, value: str) -> GcsUri:
    """Create and validate a new GcsUri instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError("gcs_uri", "Invalid GCS URI: {value}", {"value": value})
    bucket = m.group(1)
    _validate_gcs_bucket_name(bucket)
    instance = str.__new__(cls, value)
    instance.bucket = bucket
    instance.key = m.group(2) or ""
    return instance

KmsKeyName

Bases: str

A validated GCP KMS key name.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for KmsKeyName.

Source code in src/pydantypes/cloud/gcp/security.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for KmsKeyName."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for KmsKeyName.

Source code in src/pydantypes/cloud/gcp/security.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for KmsKeyName."""
    return {
        "type": "string",
        "format": "gcp-kms-key-name",
        "pattern": cls._pattern.pattern,
        "description": "A GCP KMS key name.",
        "examples": [
            "projects/my-project/locations/us-central1/keyRings/my-ring/cryptoKeys/my-key"
        ],
        "title": "KmsKeyName",
    }

__new__

__new__(value: str) -> KmsKeyName

Create and validate a new KmsKeyName instance.

Source code in src/pydantypes/cloud/gcp/security.py
def __new__(cls, value: str) -> KmsKeyName:
    """Create and validate a new KmsKeyName instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_kms_key_name",
            "Invalid GCP KMS key name: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.project_id = m.group(1)
    instance.location = m.group(2)
    instance.key_ring = m.group(3)
    instance.key_name = m.group(4)
    return instance

PubSubSubscriptionName

Bases: str

A validated GCP Pub/Sub subscription name.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for PubSubSubscriptionName.

Source code in src/pydantypes/cloud/gcp/messaging.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for PubSubSubscriptionName."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for PubSubSubscriptionName.

Source code in src/pydantypes/cloud/gcp/messaging.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for PubSubSubscriptionName."""
    return {
        "type": "string",
        "format": "gcp-pubsub-subscription-name",
        "pattern": cls._pattern.pattern,
        "description": (
            "A GCP Pub/Sub subscription name (projects/{project}/subscriptions/{subscription})."
        ),
        "examples": ["projects/my-project/subscriptions/my-subscription"],
        "title": "PubSubSubscriptionName",
    }

__new__

__new__(value: str) -> PubSubSubscriptionName

Create and validate a new PubSubSubscriptionName instance.

Source code in src/pydantypes/cloud/gcp/messaging.py
def __new__(cls, value: str) -> PubSubSubscriptionName:
    """Create and validate a new PubSubSubscriptionName instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_pubsub_subscription_name",
            "Invalid GCP Pub/Sub subscription name: {value}",
            {"value": value},
        )
    sub_name = m.group(2)
    if sub_name.lower().startswith("goog"):
        raise PydanticCustomError(
            "gcp_pubsub_subscription_name",
            "Invalid GCP Pub/Sub subscription name: must not start with 'goog'. Got: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.project_id = m.group(1)
    instance.subscription_name = sub_name
    return instance

PubSubTopicName

Bases: str

A validated GCP Pub/Sub topic name (projects/{project}/topics/{topic}).

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for PubSubTopicName.

Source code in src/pydantypes/cloud/gcp/messaging.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for PubSubTopicName."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for PubSubTopicName.

Source code in src/pydantypes/cloud/gcp/messaging.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for PubSubTopicName."""
    return {
        "type": "string",
        "format": "gcp-pubsub-topic-name",
        "pattern": cls._pattern.pattern,
        "description": "A GCP Pub/Sub topic name (projects/{project}/topics/{topic}).",
        "examples": ["projects/my-project/topics/my-topic"],
        "title": "PubSubTopicName",
    }

__new__

__new__(value: str) -> PubSubTopicName

Create and validate a new PubSubTopicName instance.

Source code in src/pydantypes/cloud/gcp/messaging.py
def __new__(cls, value: str) -> PubSubTopicName:
    """Create and validate a new PubSubTopicName instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_pubsub_topic_name",
            "Invalid GCP Pub/Sub topic name: {value}",
            {"value": value},
        )
    topic_name = m.group(2)
    if topic_name.lower().startswith("goog"):
        raise PydanticCustomError(
            "gcp_pubsub_topic_name",
            "Invalid GCP Pub/Sub topic name: must not start with 'goog'. Got: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.project_id = m.group(1)
    instance.topic_name = topic_name
    return instance

Region

Bases: StrEnum

GCP cloud regions.

SecretManagerSecretName

Bases: str

A validated GCP Secret Manager secret name (projects/{project}/secrets/{secret}).

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for SecretManagerSecretName.

Source code in src/pydantypes/cloud/gcp/security.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for SecretManagerSecretName."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for SecretManagerSecretName.

Source code in src/pydantypes/cloud/gcp/security.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for SecretManagerSecretName."""
    return {
        "type": "string",
        "format": "gcp-secret-manager-secret-name",
        "pattern": cls._pattern.pattern,
        "description": "A GCP Secret Manager secret name.",
        "examples": ["projects/my-project/secrets/my-secret"],
        "title": "SecretManagerSecretName",
    }

__new__

__new__(value: str) -> SecretManagerSecretName

Create and validate a new SecretManagerSecretName instance.

Source code in src/pydantypes/cloud/gcp/security.py
def __new__(cls, value: str) -> SecretManagerSecretName:
    """Create and validate a new SecretManagerSecretName instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_secret_manager_secret_name",
            "Invalid GCP Secret Manager secret name: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.project_id = m.group(1)
    instance.secret_id = m.group(2)
    return instance

SecretManagerVersionName

Bases: str

A validated GCP Secret Manager version name.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for SecretManagerVersionName.

Source code in src/pydantypes/cloud/gcp/security.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for SecretManagerVersionName."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for SecretManagerVersionName.

Source code in src/pydantypes/cloud/gcp/security.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for SecretManagerVersionName."""
    return {
        "type": "string",
        "format": "gcp-secret-manager-version-name",
        "pattern": cls._pattern.pattern,
        "description": "A GCP Secret Manager version name.",
        "examples": ["projects/my-project/secrets/my-secret/versions/1"],
        "title": "SecretManagerVersionName",
    }

__new__

__new__(value: str) -> SecretManagerVersionName

Create and validate a new SecretManagerVersionName instance.

Source code in src/pydantypes/cloud/gcp/security.py
def __new__(cls, value: str) -> SecretManagerVersionName:
    """Create and validate a new SecretManagerVersionName instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_secret_manager_version_name",
            "Invalid GCP Secret Manager version name: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.project_id = m.group(1)
    instance.secret_id = m.group(2)
    instance.version = m.group(3)
    return instance

ServiceAccountEmail

Bases: str

A validated GCP service account email.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for ServiceAccountEmail.

Source code in src/pydantypes/cloud/gcp/identity.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for ServiceAccountEmail."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for ServiceAccountEmail.

Source code in src/pydantypes/cloud/gcp/identity.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for ServiceAccountEmail."""
    return {
        "type": "string",
        "format": "gcp-service-account-email",
        "pattern": cls._pattern.pattern,
        "description": "A GCP service account email.",
        "examples": ["my-service-account@my-project.iam.gserviceaccount.com"],
        "title": "ServiceAccountEmail",
    }

__new__

__new__(value: str) -> ServiceAccountEmail

Create and validate a new ServiceAccountEmail instance.

Source code in src/pydantypes/cloud/gcp/identity.py
def __new__(cls, value: str) -> ServiceAccountEmail:
    """Create and validate a new ServiceAccountEmail instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "gcp_service_account_email",
            "Invalid GCP service account email: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.name = m.group(1)
    instance.project_id = m.group(2)
    return instance

Zone

Bases: str

A validated GCP zone (e.g. us-central1-a).

GCP zones use globally consistent names ({region}-{letter}), unlike AWS and Azure where zone names are randomly mapped per account/subscription. This makes GCP zones the only cloud provider zones worth validating as a type with parsed properties (.region, .zone_letter).

Source: https://cloud.google.com/compute/docs/regions-zones

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for Zone.

Source code in src/pydantypes/cloud/gcp/region.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for Zone."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for Zone.

Source code in src/pydantypes/cloud/gcp/region.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for Zone."""
    return {
        "type": "string",
        "format": "gcp-zone",
        "pattern": cls._pattern.pattern,
        "description": "A GCP zone (e.g. us-central1-a).",
        "examples": ["us-central1-a"],
        "title": "Zone",
    }

__new__

__new__(value: str) -> Zone

Create and validate a new Zone instance.

Source code in src/pydantypes/cloud/gcp/region.py
def __new__(cls, value: str) -> Zone:
    """Create and validate a new Zone instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError("gcp_zone", "Invalid GCP Zone: {value}", {"value": value})
    region_str = m.group(1)
    try:
        Region(region_str)
    except ValueError:
        raise PydanticCustomError(
            "gcp_zone",
            "Invalid GCP Zone: unknown region '{region}' in {value}",
            {"region": region_str, "value": value},
        ) from None
    instance = str.__new__(cls, value)
    instance.region = region_str
    instance.zone_letter = m.group(2)
    return instance