# generated by fastapi-codegen:
# filename: openapi.yaml
# timestamp: 2025-06-29T01:13:58+00:00
from __future__ import annotations
from enum import Enum
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field, RootModel
class BindDeviceToGatewayRequest(BaseModel):
deviceId: Optional[str] = Field(
None,
description='Required. The device to associate with the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.',
)
gatewayId: Optional[str] = Field(
None,
description='Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.',
)
class BindDeviceToGatewayResponse(BaseModel):
pass
class LogLevel(Enum):
LOG_LEVEL_UNSPECIFIED = 'LOG_LEVEL_UNSPECIFIED'
NONE = 'NONE'
ERROR = 'ERROR'
INFO = 'INFO'
DEBUG = 'DEBUG'
class DeviceConfig(BaseModel):
binaryData: Optional[str] = Field(
None, description='The device configuration data.'
)
cloudUpdateTime: Optional[str] = Field(
None,
description='[Output only] The time at which this configuration version was updated in Cloud IoT Core. This timestamp is set by the server.',
)
deviceAckTime: Optional[str] = Field(
None,
description='[Output only] The time at which Cloud IoT Core received the acknowledgment from the device, indicating that the device has received this configuration version. If this field is not present, the device has not yet acknowledged that it received this version. Note that when the config was sent to the device, many config versions may have been available in Cloud IoT Core while the device was disconnected, and on connection, only the latest version is sent to the device. Some versions may never be sent to the device, and therefore are never acknowledged. This timestamp is set by Cloud IoT Core.',
)
version: Optional[str] = Field(
None,
description='[Output only] The version of this update. The version number is assigned by the server, and is always greater than 0 after device creation. The version must be 0 on the `CreateDevice` request if a `config` is specified; the response of `CreateDevice` will always have a value of 1.',
)
class DeviceState(BaseModel):
binaryData: Optional[str] = Field(None, description='The device state data.')
updateTime: Optional[str] = Field(
None,
description='[Output only] The time at which this state version was updated in Cloud IoT Core.',
)
class Empty(BaseModel):
pass
class EventNotificationConfig(BaseModel):
pubsubTopicName: Optional[str] = Field(
None,
description='A Cloud Pub/Sub topic name. For example, `projects/myProject/topics/deviceEvents`.',
)
subfolderMatches: Optional[str] = Field(
None,
description="If the subfolder name matches this string exactly, this configuration will be used. The string must not include the leading '/' character. If empty, all strings are matched. This field is used only for telemetry events; subfolders are not supported for state changes.",
)
class Expr(BaseModel):
description: Optional[str] = Field(
None,
description='Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.',
)
expression: Optional[str] = Field(
None,
description='Textual representation of an expression in Common Expression Language syntax.',
)
location: Optional[str] = Field(
None,
description='Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.',
)
title: Optional[str] = Field(
None,
description='Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.',
)
class GatewayAuthMethod(Enum):
GATEWAY_AUTH_METHOD_UNSPECIFIED = 'GATEWAY_AUTH_METHOD_UNSPECIFIED'
ASSOCIATION_ONLY = 'ASSOCIATION_ONLY'
DEVICE_AUTH_TOKEN_ONLY = 'DEVICE_AUTH_TOKEN_ONLY'
ASSOCIATION_AND_DEVICE_AUTH_TOKEN = 'ASSOCIATION_AND_DEVICE_AUTH_TOKEN'
class GatewayType(Enum):
GATEWAY_TYPE_UNSPECIFIED = 'GATEWAY_TYPE_UNSPECIFIED'
GATEWAY = 'GATEWAY'
NON_GATEWAY = 'NON_GATEWAY'
class GatewayConfig(BaseModel):
gatewayAuthMethod: Optional[GatewayAuthMethod] = Field(
None,
description='Indicates how to authorize and/or authenticate devices to access the gateway.',
)
gatewayType: Optional[GatewayType] = Field(
None, description='Indicates whether the device is a gateway.'
)
lastAccessedGatewayId: Optional[str] = Field(
None,
description='[Output only] The ID of the gateway the device accessed most recently.',
)
lastAccessedGatewayTime: Optional[str] = Field(
None,
description='[Output only] The most recent time at which the device accessed the gateway specified in `last_accessed_gateway`.',
)
class GetPolicyOptions(BaseModel):
requestedPolicyVersion: Optional[int] = Field(
None,
description='Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).',
)
class HttpEnabledState(Enum):
HTTP_STATE_UNSPECIFIED = 'HTTP_STATE_UNSPECIFIED'
HTTP_ENABLED = 'HTTP_ENABLED'
HTTP_DISABLED = 'HTTP_DISABLED'
class HttpConfig(BaseModel):
httpEnabledState: Optional[HttpEnabledState] = Field(
None,
description='If enabled, allows devices to use DeviceService via the HTTP protocol. Otherwise, any requests to DeviceService will fail for this registry.',
)
class ListDeviceConfigVersionsResponse(BaseModel):
deviceConfigs: Optional[List[DeviceConfig]] = Field(
None,
description='The device configuration for the last few versions. Versions are listed in decreasing order, starting from the most recent one.',
)
class ListDeviceStatesResponse(BaseModel):
deviceStates: Optional[List[DeviceState]] = Field(
None,
description='The last few device states. States are listed in descending order of server update time, starting from the most recent one.',
)
class ModifyCloudToDeviceConfigRequest(BaseModel):
binaryData: Optional[str] = Field(
None, description='Required. The configuration data for the device.'
)
versionToUpdate: Optional[str] = Field(
None,
description='The version number to update. If this value is zero, it will not check the version number of the server and will always update the current version; otherwise, this update will fail if the version number found on the server does not match this version number. This is used to support multiple simultaneous updates without losing data.',
)
class MqttEnabledState(Enum):
MQTT_STATE_UNSPECIFIED = 'MQTT_STATE_UNSPECIFIED'
MQTT_ENABLED = 'MQTT_ENABLED'
MQTT_DISABLED = 'MQTT_DISABLED'
class MqttConfig(BaseModel):
mqttEnabledState: Optional[MqttEnabledState] = Field(
None,
description='If enabled, allows connections using the MQTT protocol. Otherwise, MQTT connections to this registry will fail.',
)
class Format(Enum):
UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT = (
'UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT'
)
X509_CERTIFICATE_PEM = 'X509_CERTIFICATE_PEM'
class Format1(Enum):
UNSPECIFIED_PUBLIC_KEY_FORMAT = 'UNSPECIFIED_PUBLIC_KEY_FORMAT'
RSA_PEM = 'RSA_PEM'
RSA_X509_PEM = 'RSA_X509_PEM'
ES256_PEM = 'ES256_PEM'
ES256_X509_PEM = 'ES256_X509_PEM'
class PublicKeyCredential(BaseModel):
format: Optional[Format1] = Field(None, description='The format of the key.')
key: Optional[str] = Field(None, description='The key data.')
class SendCommandToDeviceRequest(BaseModel):
binaryData: Optional[str] = Field(
None, description='Required. The command data to send to the device.'
)
subfolder: Optional[str] = Field(
None,
description='Optional subfolder for the command. If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to the /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" or "#") or null characters.',
)
class SendCommandToDeviceResponse(BaseModel):
pass
class StateNotificationConfig(BaseModel):
pubsubTopicName: Optional[str] = Field(
None,
description='A Cloud Pub/Sub topic name. For example, `projects/myProject/topics/deviceEvents`.',
)
class Status(BaseModel):
code: Optional[int] = Field(
None,
description='The status code, which should be an enum value of google.rpc.Code.',
)
details: Optional[List[Dict[str, Any]]] = Field(
None,
description='A list of messages that carry the error details. There is a common set of message types for APIs to use.',
)
message: Optional[str] = Field(
None,
description='A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.',
)
class TestIamPermissionsRequest(BaseModel):
permissions: Optional[List[str]] = Field(
None,
description='The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).',
)
class TestIamPermissionsResponse(BaseModel):
permissions: Optional[List[str]] = Field(
None,
description='A subset of `TestPermissionsRequest.permissions` that the caller is allowed.',
)
class UnbindDeviceFromGatewayRequest(BaseModel):
deviceId: Optional[str] = Field(
None,
description='Required. The device to disassociate from the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier.',
)
gatewayId: Optional[str] = Field(
None,
description='Required. The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier.',
)
class UnbindDeviceFromGatewayResponse(BaseModel):
pass
class X509CertificateDetails(BaseModel):
expiryTime: Optional[str] = Field(
None, description='The time the certificate becomes invalid.'
)
issuer: Optional[str] = Field(
None, description='The entity that signed the certificate.'
)
publicKeyType: Optional[str] = Field(
None, description='The type of public key in the certificate.'
)
signatureAlgorithm: Optional[str] = Field(
None, description='The algorithm used to sign the certificate.'
)
startTime: Optional[str] = Field(
None, description='The time the certificate becomes valid.'
)
subject: Optional[str] = Field(
None, description='The entity the certificate and public key belong to.'
)
class FieldXgafv(Enum):
field_1 = '1'
field_2 = '2'
class Alt(Enum):
json = 'json'
media = 'media'
proto = 'proto'
class GatewayListOptionsGatewayType(Enum):
GATEWAY_TYPE_UNSPECIFIED = 'GATEWAY_TYPE_UNSPECIFIED'
GATEWAY = 'GATEWAY'
NON_GATEWAY = 'NON_GATEWAY'
class DeviceIds(RootModel[List[str]]):
root: List[str]
class DeviceNumIds(RootModel[List[str]]):
root: List[str]
class Binding(BaseModel):
condition: Optional[Expr] = Field(
None,
description='The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).',
)
members: Optional[List[str]] = Field(
None,
description='Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding.',
)
role: Optional[str] = Field(
None,
description='Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`.',
)
class DeviceCredential(BaseModel):
expirationTime: Optional[str] = Field(
None,
description='[Optional] The time at which this credential becomes invalid. This credential will be ignored for new client authentication requests after this timestamp; however, it will not be automatically deleted.',
)
publicKey: Optional[PublicKeyCredential] = Field(
None,
description='A public key used to verify the signature of JSON Web Tokens (JWTs). When adding a new device credential, either via device creation or via modifications, this public key credential may be required to be signed by one of the registry level certificates. More specifically, if the registry contains at least one certificate, any new device credential must be signed by one of the registry certificates. As a result, when the registry contains certificates, only X.509 certificates are accepted as device credentials. However, if the registry does not contain a certificate, self-signed certificates and public keys will be accepted. New device credentials must be different from every registry-level certificate.',
)
class GetIamPolicyRequest(BaseModel):
options: Optional[GetPolicyOptions] = Field(
None,
description='OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.',
)
class Policy(BaseModel):
bindings: Optional[List[Binding]] = Field(
None,
description='Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.',
)
etag: Optional[str] = Field(
None,
description='`etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.',
)
version: Optional[int] = Field(
None,
description='Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).',
)
class PublicKeyCertificate(BaseModel):
certificate: Optional[str] = Field(None, description='The certificate data.')
format: Optional[Format] = Field(None, description='The certificate format.')
x509Details: Optional[X509CertificateDetails] = Field(
None,
description='[Output only] The certificate details. Used only for X.509 certificates.',
)
class RegistryCredential(BaseModel):
publicKeyCertificate: Optional[PublicKeyCertificate] = Field(
None,
description='A public key certificate used to verify the device credentials.',
)
class SetIamPolicyRequest(BaseModel):
policy: Optional[Policy] = Field(
None,
description='REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.',
)
class Device(BaseModel):
blocked: Optional[bool] = Field(
None,
description='If a device is blocked, connections or requests from this device will fail. Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.',
)
config: Optional[DeviceConfig] = Field(
None,
description='The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of `1`. To update this field after creation, use the `DeviceManager.ModifyCloudToDeviceConfig` method.',
)
credentials: Optional[List[DeviceCredential]] = Field(
None,
description='The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the `DeviceRegistry.credentials` field.',
)
gatewayConfig: Optional[GatewayConfig] = Field(
None, description='Gateway-related configuration and state.'
)
id: Optional[str] = Field(
None,
description='The user-defined device identifier. The device ID must be unique within a device registry.',
)
lastConfigAckTime: Optional[str] = Field(
None,
description='[Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.',
)
lastConfigSendTime: Optional[str] = Field(
None,
description='[Output only] The last time a cloud-to-device config version was sent to the device.',
)
lastErrorStatus: Optional[Status] = Field(
None,
description="[Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.",
)
lastErrorTime: Optional[str] = Field(
None,
description="[Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.",
)
lastEventTime: Optional[str] = Field(
None,
description='[Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.',
)
lastHeartbeatTime: Optional[str] = Field(
None,
description='[Output only] The last time an MQTT `PINGREQ` was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send `PINGREQ` messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.',
)
lastStateTime: Optional[str] = Field(
None,
description='[Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.',
)
logLevel: Optional[LogLevel] = Field(
None,
description='**Beta Feature** The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.',
)
metadata: Optional[Dict[str, str]] = Field(
None,
description='The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device. Keys must conform to the regular expression a-zA-Z+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.',
)
name: Optional[str] = Field(
None,
description='The resource path name. For example, `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. When `name` is populated as a response from the service, it always ends in the device numeric ID.',
)
numId: Optional[str] = Field(
None,
description='[Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.',
)
state: Optional[DeviceState] = Field(
None,
description='[Output only] The state most recently received from the device. If no state has been reported, this field is not present.',
)
class DeviceRegistry(BaseModel):
credentials: Optional[List[RegistryCredential]] = Field(
None,
description='The credentials used to verify the device credentials. No more than 10 credentials can be bound to a single registry at a time. The verification process occurs at the time of device creation or update. If this field is empty, no verification is performed. Otherwise, the credentials of a newly created device or added credentials of an updated device should be signed with one of these registry credentials. Note, however, that existing devices will never be affected by modifications to this list of credentials: after a device has been successfully created in a registry, it should be able to connect even if its registry credentials are revoked, deleted, or modified.',
)
eventNotificationConfigs: Optional[List[EventNotificationConfig]] = Field(
None,
description="The configuration for notification of telemetry events received from the device. All telemetry events that were successfully published by the device and acknowledged by Cloud IoT Core are guaranteed to be delivered to Cloud Pub/Sub. If multiple configurations match a message, only the first matching configuration is used. If you try to publish a device telemetry event using MQTT without specifying a Cloud Pub/Sub topic for the device's registry, the connection closes automatically. If you try to do so using an HTTP connection, an error is returned. Up to 10 configurations may be provided.",
)
httpConfig: Optional[HttpConfig] = Field(
None,
description='The DeviceService (HTTP) configuration for this device registry.',
)
id: Optional[str] = Field(
None,
description='The identifier of this device registry. For example, `myRegistry`.',
)
logLevel: Optional[LogLevel] = Field(
None,
description='**Beta Feature** The default logging verbosity for activity from devices in this registry. The verbosity level can be overridden by Device.log_level.',
)
mqttConfig: Optional[MqttConfig] = Field(
None, description='The MQTT configuration for this device registry.'
)
name: Optional[str] = Field(
None,
description='The resource path name. For example, `projects/example-project/locations/us-central1/registries/my-registry`.',
)
stateNotificationConfig: Optional[StateNotificationConfig] = Field(
None,
description="The configuration for notification of new states received from the device. State updates are guaranteed to be stored in the state history, but notifications to Cloud Pub/Sub are not guaranteed. For example, if permissions are misconfigured or the specified topic doesn't exist, no notification will be published but the state will still be stored in Cloud IoT Core.",
)
class ListDeviceRegistriesResponse(BaseModel):
deviceRegistries: Optional[List[DeviceRegistry]] = Field(
None, description='The registries that matched the query.'
)
nextPageToken: Optional[str] = Field(
None,
description='If not empty, indicates that there may be more registries that match the request; this value should be passed in a new `ListDeviceRegistriesRequest`.',
)
class ListDevicesResponse(BaseModel):
devices: Optional[List[Device]] = Field(
None, description='The devices that match the request.'
)
nextPageToken: Optional[str] = Field(
None,
description='If not empty, indicates that there may be more devices that match the request; this value should be passed in a new `ListDevicesRequest`.',
)