diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 12edee7..237a647 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:452901c74a22f9b9a3bd02bce780b8e8805c97270d424684bff809ce5be8c2a2 + digest: sha256:6244cdf9848ec661b48e5b626123ee9f6f8eb80adc9d42d7cd3c243d4ddaea79 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7092a13..e97d89e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.9" - name: Install nox run: | python -m pip install --upgrade setuptools pip wheel @@ -28,7 +28,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.9" - name: Install nox run: | python -m pip install --upgrade setuptools pip wheel diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d2aee5b..16d5a9e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.8" - name: Install nox run: | python -m pip install --upgrade setuptools pip wheel diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 87ade4d..23000c0 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -41,7 +41,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.8" - name: Install coverage run: | python -m pip install --upgrade setuptools pip wheel diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 238b87b..7323c42 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -60,16 +60,16 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb -###################### Install python 3.8.11 +###################### Install python 3.9.13 -# Download python 3.8.11 -RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz +# Download python 3.9.13 +RUN wget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz # Extract files -RUN tar -xvf Python-3.8.11.tgz +RUN tar -xvf Python-3.9.13.tgz -# Install python 3.8.11 -RUN ./Python-3.8.11/configure --enable-optimizations +# Install python 3.9.11 +RUN ./Python-3.9.13/configure --enable-optimizations RUN make altinstall ###################### Install pip diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 31425f1..12bfbf4 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -94,9 +94,9 @@ charset-normalizer==2.1.1 \ --hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \ --hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f # via requests -click==8.0.4 \ - --hash=sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1 \ - --hash=sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb +click==8.1.3 \ + --hash=sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e \ + --hash=sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48 # via # gcp-docuploader # gcp-releasetool diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0ee8c01..2537c1f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.3.0" + ".": "0.4.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 53012ae..31ae914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [0.4.0](https://github.com/googleapis/python-api-keys/compare/v0.3.0...v0.4.0) (2022-11-16) + + +### Features + +* Add typing to proto.Message based class attributes ([d336d7d](https://github.com/googleapis/python-api-keys/commit/d336d7d554296b824f7ecf38648550307e5f0cd4)) + + +### Documentation + +* **samples:** Snippetgen handling of repeated enum field ([d336d7d](https://github.com/googleapis/python-api-keys/commit/d336d7d554296b824f7ecf38648550307e5f0cd4)) + ## [0.3.0](https://github.com/googleapis/python-api-keys/compare/v0.2.2...v0.3.0) (2022-11-08) diff --git a/docs/api_keys_v2/types.rst b/docs/api_keys_v2/types.rst index 370a779..0fc06e8 100644 --- a/docs/api_keys_v2/types.rst +++ b/docs/api_keys_v2/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Api Keys v2 API .. automodule:: google.cloud.api_keys_v2.types :members: - :undoc-members: :show-inheritance: diff --git a/google/cloud/api_keys/gapic_version.py b/google/cloud/api_keys/gapic_version.py index a6ccd66..933e30b 100644 --- a/google/cloud/api_keys/gapic_version.py +++ b/google/cloud/api_keys/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.0" # {x-release-please-version} +__version__ = "0.4.0" # {x-release-please-version} diff --git a/google/cloud/api_keys_v2/services/api_keys/async_client.py b/google/cloud/api_keys_v2/services/api_keys/async_client.py index 587419a..f516fd5 100644 --- a/google/cloud/api_keys_v2/services/api_keys/async_client.py +++ b/google/cloud/api_keys_v2/services/api_keys/async_client.py @@ -16,7 +16,17 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 @@ -158,9 +168,9 @@ def transport(self) -> ApiKeysTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, ApiKeysTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the api keys client. @@ -204,13 +214,13 @@ def __init__( async def create_key( self, - request: Union[apikeys.CreateKeyRequest, dict] = None, + request: Optional[Union[apikeys.CreateKeyRequest, dict]] = None, *, - parent: str = None, - key: resources.Key = None, - key_id: str = None, + parent: Optional[str] = None, + key: Optional[resources.Key] = None, + key_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new API key. @@ -249,7 +259,7 @@ async def sample_create_key(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.CreateKeyRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.CreateKeyRequest, dict]]): The request object. Request message for `CreateKey` method. parent (:class:`str`): @@ -353,11 +363,11 @@ async def sample_create_key(): async def list_keys( self, - request: Union[apikeys.ListKeysRequest, dict] = None, + request: Optional[Union[apikeys.ListKeysRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListKeysAsyncPager: r"""Lists the API keys owned by a project. The key string of the API @@ -394,7 +404,7 @@ async def sample_list_keys(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.ListKeysRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.ListKeysRequest, dict]]): The request object. Request message for `ListKeys` method. parent (:class:`str`): @@ -471,11 +481,11 @@ async def sample_list_keys(): async def get_key( self, - request: Union[apikeys.GetKeyRequest, dict] = None, + request: Optional[Union[apikeys.GetKeyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Key: r"""Gets the metadata for an API key. The key string of the API key @@ -511,7 +521,7 @@ async def sample_get_key(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.GetKeyRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.GetKeyRequest, dict]]): The request object. Request message for `GetKey` method. name (:class:`str`): Required. The resource name of the @@ -576,11 +586,11 @@ async def sample_get_key(): async def get_key_string( self, - request: Union[apikeys.GetKeyStringRequest, dict] = None, + request: Optional[Union[apikeys.GetKeyStringRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.GetKeyStringResponse: r"""Get the key string for an API key. @@ -615,7 +625,7 @@ async def sample_get_key_string(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.GetKeyStringRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.GetKeyStringRequest, dict]]): The request object. Request message for `GetKeyString` method. name (:class:`str`): @@ -679,12 +689,12 @@ async def sample_get_key_string(): async def update_key( self, - request: Union[apikeys.UpdateKeyRequest, dict] = None, + request: Optional[Union[apikeys.UpdateKeyRequest, dict]] = None, *, - key: resources.Key = None, - update_mask: field_mask_pb2.FieldMask = None, + key: Optional[resources.Key] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Patches the modifiable fields of an API key. The key string of @@ -723,7 +733,7 @@ async def sample_update_key(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.UpdateKeyRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.UpdateKeyRequest, dict]]): The request object. Request message for `UpdateKey` method. key (:class:`google.cloud.api_keys_v2.types.Key`): @@ -817,11 +827,11 @@ async def sample_update_key(): async def delete_key( self, - request: Union[apikeys.DeleteKeyRequest, dict] = None, + request: Optional[Union[apikeys.DeleteKeyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes an API key. Deleted key can be retrieved within 30 days @@ -861,7 +871,7 @@ async def sample_delete_key(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.DeleteKeyRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.DeleteKeyRequest, dict]]): The request object. Request message for `DeleteKey` method. name (:class:`str`): @@ -938,10 +948,10 @@ async def sample_delete_key(): async def undelete_key( self, - request: Union[apikeys.UndeleteKeyRequest, dict] = None, + request: Optional[Union[apikeys.UndeleteKeyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Undeletes an API key which was deleted within 30 days. @@ -980,7 +990,7 @@ async def sample_undelete_key(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.UndeleteKeyRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.UndeleteKeyRequest, dict]]): The request object. Request message for `UndeleteKey` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1036,10 +1046,10 @@ async def sample_undelete_key(): async def lookup_key( self, - request: Union[apikeys.LookupKeyRequest, dict] = None, + request: Optional[Union[apikeys.LookupKeyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.LookupKeyResponse: r"""Find the parent project and resource name of the API key that @@ -1075,7 +1085,7 @@ async def sample_lookup_key(): print(response) Args: - request (Union[google.cloud.api_keys_v2.types.LookupKeyRequest, dict]): + request (Optional[Union[google.cloud.api_keys_v2.types.LookupKeyRequest, dict]]): The request object. Request message for `LookupKey` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1112,10 +1122,10 @@ async def sample_lookup_key(): async def get_operation( self, - request: operations_pb2.GetOperationRequest = None, + request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. diff --git a/google/cloud/api_keys_v2/services/api_keys/client.py b/google/cloud/api_keys_v2/services/api_keys/client.py index ec0dc7d..c8649fb 100644 --- a/google/cloud/api_keys_v2/services/api_keys/client.py +++ b/google/cloud/api_keys_v2/services/api_keys/client.py @@ -16,7 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union, cast +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -65,7 +76,7 @@ class ApiKeysClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[ApiKeysTransport]: """Returns an appropriate transport class. @@ -340,7 +351,7 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ApiKeysTransport, None] = None, + transport: Optional[Union[str, ApiKeysTransport]] = None, client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -441,13 +452,13 @@ def __init__( def create_key( self, - request: Union[apikeys.CreateKeyRequest, dict] = None, + request: Optional[Union[apikeys.CreateKeyRequest, dict]] = None, *, - parent: str = None, - key: resources.Key = None, - key_id: str = None, + parent: Optional[str] = None, + key: Optional[resources.Key] = None, + key_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a new API key. @@ -590,11 +601,11 @@ def sample_create_key(): def list_keys( self, - request: Union[apikeys.ListKeysRequest, dict] = None, + request: Optional[Union[apikeys.ListKeysRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListKeysPager: r"""Lists the API keys owned by a project. The key string of the API @@ -708,11 +719,11 @@ def sample_list_keys(): def get_key( self, - request: Union[apikeys.GetKeyRequest, dict] = None, + request: Optional[Union[apikeys.GetKeyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Key: r"""Gets the metadata for an API key. The key string of the API key @@ -813,11 +824,11 @@ def sample_get_key(): def get_key_string( self, - request: Union[apikeys.GetKeyStringRequest, dict] = None, + request: Optional[Union[apikeys.GetKeyStringRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.GetKeyStringResponse: r"""Get the key string for an API key. @@ -916,12 +927,12 @@ def sample_get_key_string(): def update_key( self, - request: Union[apikeys.UpdateKeyRequest, dict] = None, + request: Optional[Union[apikeys.UpdateKeyRequest, dict]] = None, *, - key: resources.Key = None, - update_mask: field_mask_pb2.FieldMask = None, + key: Optional[resources.Key] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Patches the modifiable fields of an API key. The key string of @@ -1054,11 +1065,11 @@ def sample_update_key(): def delete_key( self, - request: Union[apikeys.DeleteKeyRequest, dict] = None, + request: Optional[Union[apikeys.DeleteKeyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes an API key. Deleted key can be retrieved within 30 days @@ -1175,10 +1186,10 @@ def sample_delete_key(): def undelete_key( self, - request: Union[apikeys.UndeleteKeyRequest, dict] = None, + request: Optional[Union[apikeys.UndeleteKeyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Undeletes an API key which was deleted within 30 days. @@ -1274,10 +1285,10 @@ def sample_undelete_key(): def lookup_key( self, - request: Union[apikeys.LookupKeyRequest, dict] = None, + request: Optional[Union[apikeys.LookupKeyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.LookupKeyResponse: r"""Find the parent project and resource name of the API key that @@ -1364,10 +1375,10 @@ def __exit__(self, type, value, traceback): def get_operation( self, - request: operations_pb2.GetOperationRequest = None, + request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. diff --git a/google/cloud/api_keys_v2/services/api_keys/transports/base.py b/google/cloud/api_keys_v2/services/api_keys/transports/base.py index f011f39..9fa07e4 100644 --- a/google/cloud/api_keys_v2/services/api_keys/transports/base.py +++ b/google/cloud/api_keys_v2/services/api_keys/transports/base.py @@ -52,7 +52,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py b/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py index 48988f2..d929a60 100644 --- a/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py +++ b/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py @@ -47,14 +47,14 @@ def __init__( self, *, host: str = "apikeys.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -182,8 +182,8 @@ def __init__( def create_channel( cls, host: str = "apikeys.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py b/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py index 170b1fb..d5ce3f6 100644 --- a/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py +++ b/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py @@ -49,7 +49,7 @@ class ApiKeysGrpcAsyncIOTransport(ApiKeysTransport): def create_channel( cls, host: str = "apikeys.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -92,15 +92,15 @@ def __init__( self, *, host: str = "apikeys.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/api_keys_v2/services/api_keys/transports/rest.py b/google/cloud/api_keys_v2/services/api_keys/transports/rest.py index 9241ec2..fd56091 100644 --- a/google/cloud/api_keys_v2/services/api_keys/transports/rest.py +++ b/google/cloud/api_keys_v2/services/api_keys/transports/rest.py @@ -351,10 +351,10 @@ def __init__( self, *, host: str = "apikeys.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -480,7 +480,7 @@ def __call__( request: apikeys.CreateKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Call the create key method over HTTP. @@ -574,7 +574,7 @@ def __call__( request: apikeys.DeleteKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Call the delete key method over HTTP. @@ -659,7 +659,7 @@ def __call__( request: apikeys.GetKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Key: r"""Call the get key method over HTTP. @@ -745,7 +745,7 @@ def __call__( request: apikeys.GetKeyStringRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.GetKeyStringResponse: r"""Call the get key string method over HTTP. @@ -829,7 +829,7 @@ def __call__( request: apikeys.ListKeysRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.ListKeysResponse: r"""Call the list keys method over HTTP. @@ -915,7 +915,7 @@ def __call__( request: apikeys.LookupKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> apikeys.LookupKeyResponse: r"""Call the lookup key method over HTTP. @@ -999,7 +999,7 @@ def __call__( request: apikeys.UndeleteKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Call the undelete key method over HTTP. @@ -1093,7 +1093,7 @@ def __call__( request: apikeys.UpdateKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Call the update key method over HTTP. @@ -1240,7 +1240,7 @@ def __call__( request: operations_pb2.GetOperationRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: diff --git a/google/cloud/api_keys_v2/types/apikeys.py b/google/cloud/api_keys_v2/types/apikeys.py index 008167f..142b8fd 100644 --- a/google/cloud/api_keys_v2/types/apikeys.py +++ b/google/cloud/api_keys_v2/types/apikeys.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + from google.protobuf import field_mask_pb2 # type: ignore import proto # type: ignore @@ -60,16 +62,16 @@ class CreateKeyRequest(proto.Message): The id must NOT be a UUID-like string. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - key = proto.Field( + key: resources.Key = proto.Field( proto.MESSAGE, number=2, message=resources.Key, ) - key_id = proto.Field( + key_id: str = proto.Field( proto.STRING, number=3, ) @@ -93,19 +95,19 @@ class ListKeysRequest(proto.Message): past 30 days should also be returned. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) - show_deleted = proto.Field( + show_deleted: bool = proto.Field( proto.BOOL, number=6, ) @@ -115,7 +117,7 @@ class ListKeysResponse(proto.Message): r"""Response message for ``ListKeys`` method. Attributes: - keys (Sequence[google.cloud.api_keys_v2.types.Key]): + keys (MutableSequence[google.cloud.api_keys_v2.types.Key]): A list of API keys. next_page_token (str): The pagination token for the next page of @@ -126,12 +128,12 @@ class ListKeysResponse(proto.Message): def raw_page(self): return self - keys = proto.RepeatedField( + keys: MutableSequence[resources.Key] = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.Key, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -146,7 +148,7 @@ class GetKeyRequest(proto.Message): get. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -161,7 +163,7 @@ class GetKeyStringRequest(proto.Message): be retrieved. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -175,7 +177,7 @@ class GetKeyStringResponse(proto.Message): An encrypted and signed value of the key. """ - key_string = proto.Field( + key_string: str = proto.Field( proto.STRING, number=1, ) @@ -201,12 +203,12 @@ class UpdateKeyRequest(proto.Message): replace all allowed mutable fields. """ - key = proto.Field( + key: resources.Key = proto.Field( proto.MESSAGE, number=1, message=resources.Key, ) - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, @@ -226,11 +228,11 @@ class DeleteKeyRequest(proto.Message): used for optimistic concurrency. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - etag = proto.Field( + etag: str = proto.Field( proto.STRING, number=2, ) @@ -245,7 +247,7 @@ class UndeleteKeyRequest(proto.Message): be undeleted. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -260,7 +262,7 @@ class LookupKeyRequest(proto.Message): string value. """ - key_string = proto.Field( + key_string: str = proto.Field( proto.STRING, number=1, ) @@ -278,11 +280,11 @@ class LookupKeyResponse(proto.Message): key has been purged, resource name is empty. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=2, ) diff --git a/google/cloud/api_keys_v2/types/resources.py b/google/cloud/api_keys_v2/types/resources.py index 99f6e08..e76e6c6 100644 --- a/google/cloud/api_keys_v2/types/resources.py +++ b/google/cloud/api_keys_v2/types/resources.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -64,7 +66,7 @@ class Key(proto.Message): Output only. A timestamp when this key was deleted. If the resource is not deleted, this must be empty. - annotations (Mapping[str, str]): + annotations (MutableMapping[str, str]): Annotations is an unstructured key-value map stored with a policy that may be set by external tools to store and retrieve arbitrary metadata. @@ -81,48 +83,48 @@ class Key(proto.Message): https://google.aip.dev/154. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - uid = proto.Field( + uid: str = proto.Field( proto.STRING, number=5, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - key_string = proto.Field( + key_string: str = proto.Field( proto.STRING, number=3, ) - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp, ) - update_time = proto.Field( + update_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, ) - delete_time = proto.Field( + delete_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) - annotations = proto.MapField( + annotations: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=8, ) - restrictions = proto.Field( + restrictions: "Restrictions" = proto.Field( proto.MESSAGE, number=9, message="Restrictions", ) - etag = proto.Field( + etag: str = proto.Field( proto.STRING, number=11, ) @@ -158,7 +160,7 @@ class Restrictions(proto.Message): The iOS apps that are allowed to use the key. This field is a member of `oneof`_ ``client_restrictions``. - api_targets (Sequence[google.cloud.api_keys_v2.types.ApiTarget]): + api_targets (MutableSequence[google.cloud.api_keys_v2.types.ApiTarget]): A restriction for a specific service and optionally one or more specific methods. Requests are allowed if they match any of these @@ -166,31 +168,31 @@ class Restrictions(proto.Message): all targets are allowed. """ - browser_key_restrictions = proto.Field( + browser_key_restrictions: "BrowserKeyRestrictions" = proto.Field( proto.MESSAGE, number=1, oneof="client_restrictions", message="BrowserKeyRestrictions", ) - server_key_restrictions = proto.Field( + server_key_restrictions: "ServerKeyRestrictions" = proto.Field( proto.MESSAGE, number=2, oneof="client_restrictions", message="ServerKeyRestrictions", ) - android_key_restrictions = proto.Field( + android_key_restrictions: "AndroidKeyRestrictions" = proto.Field( proto.MESSAGE, number=3, oneof="client_restrictions", message="AndroidKeyRestrictions", ) - ios_key_restrictions = proto.Field( + ios_key_restrictions: "IosKeyRestrictions" = proto.Field( proto.MESSAGE, number=4, oneof="client_restrictions", message="IosKeyRestrictions", ) - api_targets = proto.RepeatedField( + api_targets: MutableSequence["ApiTarget"] = proto.RepeatedField( proto.MESSAGE, number=5, message="ApiTarget", @@ -202,13 +204,13 @@ class BrowserKeyRestrictions(proto.Message): key. Attributes: - allowed_referrers (Sequence[str]): + allowed_referrers (MutableSequence[str]): A list of regular expressions for the referrer URLs that are allowed to make API calls with this key. """ - allowed_referrers = proto.RepeatedField( + allowed_referrers: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=1, ) @@ -218,12 +220,12 @@ class ServerKeyRestrictions(proto.Message): r"""The IP addresses of callers that are allowed to use the key. Attributes: - allowed_ips (Sequence[str]): + allowed_ips (MutableSequence[str]): A list of the caller IP addresses that are allowed to make API calls with this key. """ - allowed_ips = proto.RepeatedField( + allowed_ips: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=1, ) @@ -233,12 +235,12 @@ class AndroidKeyRestrictions(proto.Message): r"""The Android apps that are allowed to use the key. Attributes: - allowed_applications (Sequence[google.cloud.api_keys_v2.types.AndroidApplication]): + allowed_applications (MutableSequence[google.cloud.api_keys_v2.types.AndroidApplication]): A list of Android applications that are allowed to make API calls with this key. """ - allowed_applications = proto.RepeatedField( + allowed_applications: MutableSequence["AndroidApplication"] = proto.RepeatedField( proto.MESSAGE, number=1, message="AndroidApplication", @@ -259,11 +261,11 @@ class AndroidApplication(proto.Message): The package name of the application. """ - sha1_fingerprint = proto.Field( + sha1_fingerprint: str = proto.Field( proto.STRING, number=1, ) - package_name = proto.Field( + package_name: str = proto.Field( proto.STRING, number=2, ) @@ -273,12 +275,12 @@ class IosKeyRestrictions(proto.Message): r"""The iOS apps that are allowed to use the key. Attributes: - allowed_bundle_ids (Sequence[str]): + allowed_bundle_ids (MutableSequence[str]): A list of bundle IDs that are allowed when making API calls with this key. """ - allowed_bundle_ids = proto.RepeatedField( + allowed_bundle_ids: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=1, ) @@ -295,7 +297,7 @@ class ApiTarget(proto.Message): can use ```gcloud services list`` `__ to get a list of services that are enabled in the project. - methods (Sequence[str]): + methods (MutableSequence[str]): Optional. List of one or more methods that can be called. If empty, all methods for the service are allowed. A wildcard (*) can be used as the last symbol. Valid examples: @@ -303,11 +305,11 @@ class ApiTarget(proto.Message): ``TranslateText`` ``Get*`` ``translate.googleapis.com.Get*`` """ - service = proto.Field( + service: str = proto.Field( proto.STRING, number=1, ) - methods = proto.RepeatedField( + methods: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=2, ) diff --git a/noxfile.py b/noxfile.py index 29d0200..d8440c0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -273,7 +273,7 @@ def cover(session): session.run("coverage", "erase") -@nox.session(python=DEFAULT_PYTHON_VERSION) +@nox.session(python="3.9") def docs(session): """Build the docs for this library.""" @@ -299,7 +299,7 @@ def docs(session): ) -@nox.session(python=DEFAULT_PYTHON_VERSION) +@nox.session(python="3.9") def docfx(session): """Build the docfx yaml files for this library.""" diff --git a/release-please-config.json b/release-please-config.json index ce0ee8a..eaf744d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,7 +4,12 @@ ".": { "release-type": "python", "extra-files": [ - "google/cloud/api_keys/gapic_version.py" + "google/cloud/api_keys/gapic_version.py", + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json", + "jsonpath": "$.clientLibrary.version" + } ] } }, diff --git a/samples/generated_samples/snippet_metadata_api keys_v2.json b/samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json similarity index 99% rename from samples/generated_samples/snippet_metadata_api keys_v2.json rename to samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json index c92eebc..7c8f0f7 100644 --- a/samples/generated_samples/snippet_metadata_api keys_v2.json +++ b/samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-api-keys" + "name": "google-cloud-api-keys", + "version": "0.4.0" }, "snippets": [ { diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index aca9f2d..6f3158c 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -4,8 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -# This file is intentionally left empty to test the -# latest versions of dependencies. google-api-core==1.33.2 proto-plus==1.22.0 protobuf==3.19.5