Skip to content

Commit

Permalink
feat: enable "rest" transport in Python for services supporting numer…
Browse files Browse the repository at this point in the history
…ic enums (#377)

* feat: enable "rest" transport in Python for services supporting numeric enums

PiperOrigin-RevId: 508143576

Source-Link: googleapis/googleapis@7a702a9

Source-Link: googleapis/googleapis-gen@6ad1279
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFkMTI3OWMwZTdhYTc4N2FjNmI2NmM5ZmQ0YTIxMDY5MmVkZmZjZCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* update replacement in owlbot.py

* fix: Add service_yaml_parameters to py_gapic_library BUILD.bazel targets

PiperOrigin-RevId: 510187992

Source-Link: googleapis/googleapis@5edc235

Source-Link: googleapis/googleapis-gen@b0bedb7
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBiZWRiNzJlNDc2NWEzZTBiNjc0YTI4YzUwZWEwZjlhOWIyNmE4OSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* update system test to use REST

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people authored Feb 21, 2023
1 parent 0c7ecd1 commit 9ca82a6
Show file tree
Hide file tree
Showing 19 changed files with 18,391 additions and 1,149 deletions.
160 changes: 160 additions & 0 deletions packages/google-cloud-kms/google/cloud/kms_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@
]
}
}
},
"rest": {
"libraryClient": "EkmServiceClient",
"rpcs": {
"CreateEkmConnection": {
"methods": [
"create_ekm_connection"
]
},
"GetEkmConnection": {
"methods": [
"get_ekm_connection"
]
},
"ListEkmConnections": {
"methods": [
"list_ekm_connections"
]
},
"UpdateEkmConnection": {
"methods": [
"update_ekm_connection"
]
}
}
}
}
},
Expand Down Expand Up @@ -330,6 +355,141 @@
]
}
}
},
"rest": {
"libraryClient": "KeyManagementServiceClient",
"rpcs": {
"AsymmetricDecrypt": {
"methods": [
"asymmetric_decrypt"
]
},
"AsymmetricSign": {
"methods": [
"asymmetric_sign"
]
},
"CreateCryptoKey": {
"methods": [
"create_crypto_key"
]
},
"CreateCryptoKeyVersion": {
"methods": [
"create_crypto_key_version"
]
},
"CreateImportJob": {
"methods": [
"create_import_job"
]
},
"CreateKeyRing": {
"methods": [
"create_key_ring"
]
},
"Decrypt": {
"methods": [
"decrypt"
]
},
"DestroyCryptoKeyVersion": {
"methods": [
"destroy_crypto_key_version"
]
},
"Encrypt": {
"methods": [
"encrypt"
]
},
"GenerateRandomBytes": {
"methods": [
"generate_random_bytes"
]
},
"GetCryptoKey": {
"methods": [
"get_crypto_key"
]
},
"GetCryptoKeyVersion": {
"methods": [
"get_crypto_key_version"
]
},
"GetImportJob": {
"methods": [
"get_import_job"
]
},
"GetKeyRing": {
"methods": [
"get_key_ring"
]
},
"GetPublicKey": {
"methods": [
"get_public_key"
]
},
"ImportCryptoKeyVersion": {
"methods": [
"import_crypto_key_version"
]
},
"ListCryptoKeyVersions": {
"methods": [
"list_crypto_key_versions"
]
},
"ListCryptoKeys": {
"methods": [
"list_crypto_keys"
]
},
"ListImportJobs": {
"methods": [
"list_import_jobs"
]
},
"ListKeyRings": {
"methods": [
"list_key_rings"
]
},
"MacSign": {
"methods": [
"mac_sign"
]
},
"MacVerify": {
"methods": [
"mac_verify"
]
},
"RestoreCryptoKeyVersion": {
"methods": [
"restore_crypto_key_version"
]
},
"UpdateCryptoKey": {
"methods": [
"update_crypto_key"
]
},
"UpdateCryptoKeyPrimaryVersion": {
"methods": [
"update_crypto_key_primary_version"
]
},
"UpdateCryptoKeyVersion": {
"methods": [
"update_crypto_key_version"
]
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore

from google.cloud.location import locations_pb2 # type: ignore
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
Expand Down Expand Up @@ -755,6 +756,114 @@ async def sample_update_ekm_connection():
# Done; return the response.
return response

async def get_location(
self,
request: Optional[locations_pb2.GetLocationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> locations_pb2.Location:
r"""Gets information about a location.
Args:
request (:class:`~.location_pb2.GetLocationRequest`):
The request object. Request message for
`GetLocation` method.
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.location_pb2.Location:
Location object.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = locations_pb2.GetLocationRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._client._transport.get_location,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def list_locations(
self,
request: Optional[locations_pb2.ListLocationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> locations_pb2.ListLocationsResponse:
r"""Lists information about the supported locations for this service.
Args:
request (:class:`~.location_pb2.ListLocationsRequest`):
The request object. Request message for
`ListLocations` method.
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.location_pb2.ListLocationsResponse:
Response message for ``ListLocations`` method.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = locations_pb2.ListLocationsRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._client._transport.list_locations,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def set_iam_policy(
self,
request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
Expand Down
Loading

0 comments on commit 9ca82a6

Please sign in to comment.