diff --git a/.github/release-please.yml b/.github/release-please.yml index 29601ad..fe749ff 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,5 +1,6 @@ releaseType: python handleGHRelease: true +manifest: true # NOTE: this section is generated by synthtool.languages.python # See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py branches: diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..a3906fc --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "2.9.0" +} diff --git a/docs/iam_credentials_v1/types.rst b/docs/iam_credentials_v1/types.rst index 665288e..5f3be42 100644 --- a/docs/iam_credentials_v1/types.rst +++ b/docs/iam_credentials_v1/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Iam Credentials v1 API .. automodule:: google.cloud.iam_credentials_v1.types :members: - :undoc-members: :show-inheritance: diff --git a/docs/iam_v2/types.rst b/docs/iam_v2/types.rst index 00a7f65..6b719c7 100644 --- a/docs/iam_v2/types.rst +++ b/docs/iam_v2/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Iam v2 API .. automodule:: google.cloud.iam_v2.types :members: - :undoc-members: :show-inheritance: diff --git a/docs/iam_v2beta/types.rst b/docs/iam_v2beta/types.rst index b959bff..32ff020 100644 --- a/docs/iam_v2beta/types.rst +++ b/docs/iam_v2beta/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Iam v2beta API .. automodule:: google.cloud.iam_v2beta.types :members: - :undoc-members: :show-inheritance: diff --git a/google/cloud/iam/__init__.py b/google/cloud/iam/__init__.py new file mode 100644 index 0000000..a53f64c --- /dev/null +++ b/google/cloud/iam/__init__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from google.cloud.iam import gapic_version as package_version + +__version__ = package_version.__version__ + + +from google.cloud.iam_v2.services.policies.async_client import PoliciesAsyncClient +from google.cloud.iam_v2.services.policies.client import PoliciesClient +from google.cloud.iam_v2.types.deny import DenyRule +from google.cloud.iam_v2.types.policy import ( + CreatePolicyRequest, + DeletePolicyRequest, + GetPolicyRequest, + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + PolicyOperationMetadata, + PolicyRule, + UpdatePolicyRequest, +) + +__all__ = ( + "PoliciesClient", + "PoliciesAsyncClient", + "DenyRule", + "CreatePolicyRequest", + "DeletePolicyRequest", + "GetPolicyRequest", + "ListPoliciesRequest", + "ListPoliciesResponse", + "Policy", + "PolicyOperationMetadata", + "PolicyRule", + "UpdatePolicyRequest", +) diff --git a/google/cloud/iam/gapic_version.py b/google/cloud/iam/gapic_version.py new file mode 100644 index 0000000..60aeb18 --- /dev/null +++ b/google/cloud/iam/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "2.9.0" # {x-release-please-version} diff --git a/google/cloud/iam/py.typed b/google/cloud/iam/py.typed new file mode 100644 index 0000000..a8a7868 --- /dev/null +++ b/google/cloud/iam/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-iam package uses inline types. diff --git a/google/cloud/iam_credentials/__init__.py b/google/cloud/iam_credentials/__init__.py index bbc71b4..13b83ce 100644 --- a/google/cloud/iam_credentials/__init__.py +++ b/google/cloud/iam_credentials/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.iam_credentials import gapic_version as package_version + +__version__ = package_version.__version__ + from google.cloud.iam_credentials_v1.services.iam_credentials.async_client import ( IAMCredentialsAsyncClient, diff --git a/google/cloud/iam_credentials/gapic_version.py b/google/cloud/iam_credentials/gapic_version.py new file mode 100644 index 0000000..60aeb18 --- /dev/null +++ b/google/cloud/iam_credentials/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "2.9.0" # {x-release-please-version} diff --git a/google/cloud/iam_credentials_v1/__init__.py b/google/cloud/iam_credentials_v1/__init__.py index f7b3fa3..2eb607e 100644 --- a/google/cloud/iam_credentials_v1/__init__.py +++ b/google/cloud/iam_credentials_v1/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.iam_credentials import gapic_version as package_version + +__version__ = package_version.__version__ + from .services.iam_credentials import IAMCredentialsAsyncClient, IAMCredentialsClient from .types.common import ( diff --git a/google/cloud/iam_credentials_v1/services/iam_credentials/async_client.py b/google/cloud/iam_credentials_v1/services/iam_credentials/async_client.py index e369c2a..a74ad89 100644 --- a/google/cloud/iam_credentials_v1/services/iam_credentials/async_client.py +++ b/google/cloud/iam_credentials_v1/services/iam_credentials/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 @@ -173,9 +183,9 @@ def transport(self) -> IAMCredentialsTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, IAMCredentialsTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the iam credentials client. @@ -219,14 +229,14 @@ def __init__( async def generate_access_token( self, - request: Union[common.GenerateAccessTokenRequest, dict] = None, + request: Optional[Union[common.GenerateAccessTokenRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - scope: Sequence[str] = None, - lifetime: duration_pb2.Duration = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + scope: Optional[MutableSequence[str]] = None, + lifetime: Optional[duration_pb2.Duration] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.GenerateAccessTokenResponse: r"""Generates an OAuth 2.0 access token for a service @@ -260,7 +270,7 @@ async def sample_generate_access_token(): print(response) Args: - request (Union[google.cloud.iam_credentials_v1.types.GenerateAccessTokenRequest, dict]): + request (Optional[Union[google.cloud.iam_credentials_v1.types.GenerateAccessTokenRequest, dict]]): The request object. name (:class:`str`): Required. The resource name of the service account for @@ -273,7 +283,7 @@ async def sample_generate_access_token(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (:class:`Sequence[str]`): + delegates (:class:`MutableSequence[str]`): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its @@ -291,7 +301,7 @@ async def sample_generate_access_token(): This corresponds to the ``delegates`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - scope (:class:`Sequence[str]`): + scope (:class:`MutableSequence[str]`): Required. Code to identify the scopes to be included in the OAuth 2.0 access token. See @@ -383,14 +393,14 @@ async def sample_generate_access_token(): async def generate_id_token( self, - request: Union[common.GenerateIdTokenRequest, dict] = None, + request: Optional[Union[common.GenerateIdTokenRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - audience: str = None, - include_email: bool = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + audience: Optional[str] = None, + include_email: Optional[bool] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.GenerateIdTokenResponse: r"""Generates an OpenID Connect ID token for a service @@ -424,7 +434,7 @@ async def sample_generate_id_token(): print(response) Args: - request (Union[google.cloud.iam_credentials_v1.types.GenerateIdTokenRequest, dict]): + request (Optional[Union[google.cloud.iam_credentials_v1.types.GenerateIdTokenRequest, dict]]): The request object. name (:class:`str`): Required. The resource name of the service account for @@ -437,7 +447,7 @@ async def sample_generate_id_token(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (:class:`Sequence[str]`): + delegates (:class:`MutableSequence[str]`): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its @@ -541,13 +551,13 @@ async def sample_generate_id_token(): async def sign_blob( self, - request: Union[common.SignBlobRequest, dict] = None, + request: Optional[Union[common.SignBlobRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - payload: bytes = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + payload: Optional[bytes] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.SignBlobResponse: r"""Signs a blob using a service account's system-managed @@ -581,7 +591,7 @@ async def sample_sign_blob(): print(response) Args: - request (Union[google.cloud.iam_credentials_v1.types.SignBlobRequest, dict]): + request (Optional[Union[google.cloud.iam_credentials_v1.types.SignBlobRequest, dict]]): The request object. name (:class:`str`): Required. The resource name of the service account for @@ -594,7 +604,7 @@ async def sample_sign_blob(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (:class:`Sequence[str]`): + delegates (:class:`MutableSequence[str]`): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its @@ -685,13 +695,13 @@ async def sample_sign_blob(): async def sign_jwt( self, - request: Union[common.SignJwtRequest, dict] = None, + request: Optional[Union[common.SignJwtRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - payload: str = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + payload: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.SignJwtResponse: r"""Signs a JWT using a service account's system-managed @@ -725,7 +735,7 @@ async def sample_sign_jwt(): print(response) Args: - request (Union[google.cloud.iam_credentials_v1.types.SignJwtRequest, dict]): + request (Optional[Union[google.cloud.iam_credentials_v1.types.SignJwtRequest, dict]]): The request object. name (:class:`str`): Required. The resource name of the service account for @@ -738,7 +748,7 @@ async def sample_sign_jwt(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (:class:`Sequence[str]`): + delegates (:class:`MutableSequence[str]`): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its diff --git a/google/cloud/iam_credentials_v1/services/iam_credentials/client.py b/google/cloud/iam_credentials_v1/services/iam_credentials/client.py index ecb432d..ced2e5b 100644 --- a/google/cloud/iam_credentials_v1/services/iam_credentials/client.py +++ b/google/cloud/iam_credentials_v1/services/iam_credentials/client.py @@ -16,7 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +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 @@ -60,7 +71,7 @@ class IAMCredentialsClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[IAMCredentialsTransport]: """Returns an appropriate transport class. @@ -343,8 +354,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, IAMCredentialsTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, IAMCredentialsTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the iam credentials client. @@ -358,7 +369,7 @@ def __init__( transport (Union[str, IAMCredentialsTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -388,6 +399,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -440,14 +452,14 @@ def __init__( def generate_access_token( self, - request: Union[common.GenerateAccessTokenRequest, dict] = None, + request: Optional[Union[common.GenerateAccessTokenRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - scope: Sequence[str] = None, - lifetime: duration_pb2.Duration = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + scope: Optional[MutableSequence[str]] = None, + lifetime: Optional[duration_pb2.Duration] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.GenerateAccessTokenResponse: r"""Generates an OAuth 2.0 access token for a service @@ -494,7 +506,7 @@ def sample_generate_access_token(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its @@ -512,7 +524,7 @@ def sample_generate_access_token(): This corresponds to the ``delegates`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - scope (Sequence[str]): + scope (MutableSequence[str]): Required. Code to identify the scopes to be included in the OAuth 2.0 access token. See @@ -594,14 +606,14 @@ def sample_generate_access_token(): def generate_id_token( self, - request: Union[common.GenerateIdTokenRequest, dict] = None, + request: Optional[Union[common.GenerateIdTokenRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - audience: str = None, - include_email: bool = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + audience: Optional[str] = None, + include_email: Optional[bool] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.GenerateIdTokenResponse: r"""Generates an OpenID Connect ID token for a service @@ -648,7 +660,7 @@ def sample_generate_id_token(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its @@ -742,13 +754,13 @@ def sample_generate_id_token(): def sign_blob( self, - request: Union[common.SignBlobRequest, dict] = None, + request: Optional[Union[common.SignBlobRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - payload: bytes = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + payload: Optional[bytes] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.SignBlobResponse: r"""Signs a blob using a service account's system-managed @@ -795,7 +807,7 @@ def sample_sign_blob(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its @@ -876,13 +888,13 @@ def sample_sign_blob(): def sign_jwt( self, - request: Union[common.SignJwtRequest, dict] = None, + request: Optional[Union[common.SignJwtRequest, dict]] = None, *, - name: str = None, - delegates: Sequence[str] = None, - payload: str = None, + name: Optional[str] = None, + delegates: Optional[MutableSequence[str]] = None, + payload: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.SignJwtResponse: r"""Signs a JWT using a service account's system-managed @@ -929,7 +941,7 @@ def sample_sign_jwt(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its diff --git a/google/cloud/iam_credentials_v1/services/iam_credentials/transports/base.py b/google/cloud/iam_credentials_v1/services/iam_credentials/transports/base.py index b5987c5..85be529 100644 --- a/google/cloud/iam_credentials_v1/services/iam_credentials/transports/base.py +++ b/google/cloud/iam_credentials_v1/services/iam_credentials/transports/base.py @@ -48,7 +48,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/iam_credentials_v1/services/iam_credentials/transports/grpc.py b/google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc.py index 39c547a..a006694 100644 --- a/google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc.py +++ b/google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc.py @@ -55,14 +55,14 @@ def __init__( self, *, host: str = "iamcredentials.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, @@ -189,8 +189,8 @@ def __init__( def create_channel( cls, host: str = "iamcredentials.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/iam_credentials_v1/services/iam_credentials/transports/grpc_asyncio.py b/google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc_asyncio.py index fe09ef2..2d38dbe 100644 --- a/google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc_asyncio.py +++ b/google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc_asyncio.py @@ -57,7 +57,7 @@ class IAMCredentialsGrpcAsyncIOTransport(IAMCredentialsTransport): def create_channel( cls, host: str = "iamcredentials.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, @@ -100,15 +100,15 @@ def __init__( self, *, host: str = "iamcredentials.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/iam_credentials_v1/types/common.py b/google/cloud/iam_credentials_v1/types/common.py index 210ddad..f35d100 100644 --- a/google/cloud/iam_credentials_v1/types/common.py +++ b/google/cloud/iam_credentials_v1/types/common.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 duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -42,7 +44,7 @@ class GenerateAccessTokenRequest(proto.Message): ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``. The ``-`` wildcard character is required; replacing it with a project ID is invalid. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its next @@ -56,7 +58,7 @@ class GenerateAccessTokenRequest(proto.Message): ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``. The ``-`` wildcard character is required; replacing it with a project ID is invalid. - scope (Sequence[str]): + scope (MutableSequence[str]): Required. Code to identify the scopes to be included in the OAuth 2.0 access token. See https://developers.google.com/identity/protocols/googlescopes @@ -70,19 +72,19 @@ class GenerateAccessTokenRequest(proto.Message): to a default value of one hour. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - delegates = proto.RepeatedField( + delegates: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=2, ) - scope = proto.RepeatedField( + scope: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=4, ) - lifetime = proto.Field( + lifetime: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=7, message=duration_pb2.Duration, @@ -100,11 +102,11 @@ class GenerateAccessTokenResponse(proto.Message): The expiration time is always set. """ - access_token = proto.Field( + access_token: str = proto.Field( proto.STRING, number=1, ) - expire_time = proto.Field( + expire_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, @@ -121,7 +123,7 @@ class SignBlobRequest(proto.Message): ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``. The ``-`` wildcard character is required; replacing it with a project ID is invalid. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its next @@ -139,15 +141,15 @@ class SignBlobRequest(proto.Message): Required. The bytes to sign. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - delegates = proto.RepeatedField( + delegates: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) - payload = proto.Field( + payload: bytes = proto.Field( proto.BYTES, number=5, ) @@ -163,11 +165,11 @@ class SignBlobResponse(proto.Message): The signed blob. """ - key_id = proto.Field( + key_id: str = proto.Field( proto.STRING, number=1, ) - signed_blob = proto.Field( + signed_blob: bytes = proto.Field( proto.BYTES, number=4, ) @@ -183,7 +185,7 @@ class SignJwtRequest(proto.Message): ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``. The ``-`` wildcard character is required; replacing it with a project ID is invalid. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its next @@ -202,15 +204,15 @@ class SignJwtRequest(proto.Message): object that contains a JWT Claims Set. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - delegates = proto.RepeatedField( + delegates: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) - payload = proto.Field( + payload: str = proto.Field( proto.STRING, number=5, ) @@ -226,11 +228,11 @@ class SignJwtResponse(proto.Message): The signed JWT. """ - key_id = proto.Field( + key_id: str = proto.Field( proto.STRING, number=1, ) - signed_jwt = proto.Field( + signed_jwt: str = proto.Field( proto.STRING, number=2, ) @@ -246,7 +248,7 @@ class GenerateIdTokenRequest(proto.Message): ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``. The ``-`` wildcard character is required; replacing it with a project ID is invalid. - delegates (Sequence[str]): + delegates (MutableSequence[str]): The sequence of service accounts in a delegation chain. Each service account must be granted the ``roles/iam.serviceAccountTokenCreator`` role on its next @@ -270,19 +272,19 @@ class GenerateIdTokenRequest(proto.Message): ``email_verified`` claims. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - delegates = proto.RepeatedField( + delegates: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=2, ) - audience = proto.Field( + audience: str = proto.Field( proto.STRING, number=3, ) - include_email = proto.Field( + include_email: bool = proto.Field( proto.BOOL, number=4, ) @@ -296,7 +298,7 @@ class GenerateIdTokenResponse(proto.Message): The OpenId Connect ID token. """ - token = proto.Field( + token: str = proto.Field( proto.STRING, number=1, ) diff --git a/google/cloud/iam_v2/__init__.py b/google/cloud/iam_v2/__init__.py index cc79688..f30b671 100644 --- a/google/cloud/iam_v2/__init__.py +++ b/google/cloud/iam_v2/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.iam import gapic_version as package_version + +__version__ = package_version.__version__ + from .services.policies import PoliciesAsyncClient, PoliciesClient from .types.deny import DenyRule diff --git a/google/cloud/iam_v2/services/policies/async_client.py b/google/cloud/iam_v2/services/policies/async_client.py index d852af6..497bc48 100644 --- a/google/cloud/iam_v2/services/policies/async_client.py +++ b/google/cloud/iam_v2/services/policies/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 @@ -157,9 +167,9 @@ def transport(self) -> PoliciesTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, PoliciesTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the policies client. @@ -203,11 +213,11 @@ def __init__( async def list_policies( self, - request: Union[policy.ListPoliciesRequest, dict] = None, + request: Optional[Union[policy.ListPoliciesRequest, 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.ListPoliciesAsyncPager: r"""Retrieves the policies of the specified kind that are @@ -244,7 +254,7 @@ async def sample_list_policies(): print(response) Args: - request (Union[google.cloud.iam_v2.types.ListPoliciesRequest, dict]): + request (Optional[Union[google.cloud.iam_v2.types.ListPoliciesRequest, dict]]): The request object. Request message for `ListPolicies`. parent (:class:`str`): Required. The resource that the policy is attached to, @@ -340,11 +350,11 @@ async def sample_list_policies(): async def get_policy( self, - request: Union[policy.GetPolicyRequest, dict] = None, + request: Optional[Union[policy.GetPolicyRequest, 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]] = (), ) -> policy.Policy: r"""Gets a policy. @@ -376,7 +386,7 @@ async def sample_get_policy(): print(response) Args: - request (Union[google.cloud.iam_v2.types.GetPolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2.types.GetPolicyRequest, dict]]): The request object. Request message for `GetPolicy`. name (:class:`str`): Required. The resource name of the policy to retrieve. @@ -458,13 +468,13 @@ async def sample_get_policy(): async def create_policy( self, - request: Union[gi_policy.CreatePolicyRequest, dict] = None, + request: Optional[Union[gi_policy.CreatePolicyRequest, dict]] = None, *, - parent: str = None, - policy: gi_policy.Policy = None, - policy_id: str = None, + parent: Optional[str] = None, + policy: Optional[gi_policy.Policy] = None, + policy_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 policy. @@ -500,7 +510,7 @@ async def sample_create_policy(): print(response) Args: - request (Union[google.cloud.iam_v2.types.CreatePolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2.types.CreatePolicyRequest, dict]]): The request object. Request message for `CreatePolicy`. parent (:class:`str`): Required. The resource that the policy is attached to, @@ -616,10 +626,10 @@ async def sample_create_policy(): async def update_policy( self, - request: Union[policy.UpdatePolicyRequest, dict] = None, + request: Optional[Union[policy.UpdatePolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified policy. @@ -666,7 +676,7 @@ async def sample_update_policy(): print(response) Args: - request (Union[google.cloud.iam_v2.types.UpdatePolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2.types.UpdatePolicyRequest, dict]]): The request object. Request message for `UpdatePolicy`. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -732,11 +742,11 @@ async def sample_update_policy(): async def delete_policy( self, - request: Union[policy.DeletePolicyRequest, dict] = None, + request: Optional[Union[policy.DeletePolicyRequest, 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 a policy. This action is permanent. @@ -772,7 +782,7 @@ async def sample_delete_policy(): print(response) Args: - request (Union[google.cloud.iam_v2.types.DeletePolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2.types.DeletePolicyRequest, dict]]): The request object. Request message for `DeletePolicy`. name (:class:`str`): Required. The resource name of the policy to delete. @@ -867,10 +877,10 @@ async def sample_delete_policy(): 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/iam_v2/services/policies/client.py b/google/cloud/iam_v2/services/policies/client.py index d503855..60d1e34 100644 --- a/google/cloud/iam_v2/services/policies/client.py +++ b/google/cloud/iam_v2/services/policies/client.py @@ -16,7 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +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 @@ -62,7 +73,7 @@ class PoliciesClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[PoliciesTransport]: """Returns an appropriate transport class. @@ -317,8 +328,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, PoliciesTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, PoliciesTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the policies client. @@ -332,7 +343,7 @@ def __init__( transport (Union[str, PoliciesTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -362,6 +373,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -414,11 +426,11 @@ def __init__( def list_policies( self, - request: Union[policy.ListPoliciesRequest, dict] = None, + request: Optional[Union[policy.ListPoliciesRequest, 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.ListPoliciesPager: r"""Retrieves the policies of the specified kind that are @@ -542,11 +554,11 @@ def sample_list_policies(): def get_policy( self, - request: Union[policy.GetPolicyRequest, dict] = None, + request: Optional[Union[policy.GetPolicyRequest, 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]] = (), ) -> policy.Policy: r"""Gets a policy. @@ -651,13 +663,13 @@ def sample_get_policy(): def create_policy( self, - request: Union[gi_policy.CreatePolicyRequest, dict] = None, + request: Optional[Union[gi_policy.CreatePolicyRequest, dict]] = None, *, - parent: str = None, - policy: gi_policy.Policy = None, - policy_id: str = None, + parent: Optional[str] = None, + policy: Optional[gi_policy.Policy] = None, + policy_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 policy. @@ -800,10 +812,10 @@ def sample_create_policy(): def update_policy( self, - request: Union[policy.UpdatePolicyRequest, dict] = None, + request: Optional[Union[policy.UpdatePolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Updates the specified policy. @@ -908,11 +920,11 @@ def sample_update_policy(): def delete_policy( self, - request: Union[policy.DeletePolicyRequest, dict] = None, + request: Optional[Union[policy.DeletePolicyRequest, 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 a policy. This action is permanent. @@ -1047,10 +1059,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/iam_v2/services/policies/transports/base.py b/google/cloud/iam_v2/services/policies/transports/base.py index f90a697..f692688 100644 --- a/google/cloud/iam_v2/services/policies/transports/base.py +++ b/google/cloud/iam_v2/services/policies/transports/base.py @@ -50,7 +50,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/iam_v2/services/policies/transports/grpc.py b/google/cloud/iam_v2/services/policies/transports/grpc.py index f09c345..4c9712d 100644 --- a/google/cloud/iam_v2/services/policies/transports/grpc.py +++ b/google/cloud/iam_v2/services/policies/transports/grpc.py @@ -49,14 +49,14 @@ def __init__( self, *, host: str = "iam.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, @@ -184,8 +184,8 @@ def __init__( def create_channel( cls, host: str = "iam.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/iam_v2/services/policies/transports/grpc_asyncio.py b/google/cloud/iam_v2/services/policies/transports/grpc_asyncio.py index 1261531..c8988bb 100644 --- a/google/cloud/iam_v2/services/policies/transports/grpc_asyncio.py +++ b/google/cloud/iam_v2/services/policies/transports/grpc_asyncio.py @@ -51,7 +51,7 @@ class PoliciesGrpcAsyncIOTransport(PoliciesTransport): def create_channel( cls, host: str = "iam.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, @@ -94,15 +94,15 @@ def __init__( self, *, host: str = "iam.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/iam_v2/types/deny.py b/google/cloud/iam_v2/types/deny.py index a3dd76c..f526f97 100644 --- a/google/cloud/iam_v2/types/deny.py +++ b/google/cloud/iam_v2/types/deny.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.type import expr_pb2 # type: ignore import proto # type: ignore @@ -28,7 +30,7 @@ class DenyRule(proto.Message): r"""A deny rule in an IAM deny policy. Attributes: - denied_principals (Sequence[str]): + denied_principals (MutableSequence[str]): The identities that are prevented from using one or more permissions on Google Cloud resources. This field can contain the following values: @@ -76,7 +78,7 @@ class DenyRule(proto.Message): Google Workspace or Cloud Identity customer ID. For example, ``principalSet://goog/cloudIdentityCustomerId/C01Abc35``. - exception_principals (Sequence[str]): + exception_principals (MutableSequence[str]): The identities that are excluded from the deny rule, even if they are listed in the ``denied_principals``. For example, you could add a Google group to the ``denied_principals``, @@ -86,13 +88,13 @@ class DenyRule(proto.Message): ``denied_principals`` field, excluding ``principalSet://goog/public:all``, which represents all users on the internet. - denied_permissions (Sequence[str]): + denied_permissions (MutableSequence[str]): The permissions that are explicitly denied by this rule. Each permission uses the format ``{service_fqdn}/{resource}.{verb}``, where ``{service_fqdn}`` is the fully qualified domain name for the service. For example, ``iam.googleapis.com/roles.list``. - exception_permissions (Sequence[str]): + exception_permissions (MutableSequence[str]): Specifies the permissions that this rule excludes from the set of denied permissions given by ``denied_permissions``. If a permission appears in ``denied_permissions`` *and* in @@ -115,23 +117,23 @@ class DenyRule(proto.Message): Other functions and operators are not supported. """ - denied_principals = proto.RepeatedField( + denied_principals: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=1, ) - exception_principals = proto.RepeatedField( + exception_principals: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=2, ) - denied_permissions = proto.RepeatedField( + denied_permissions: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) - exception_permissions = proto.RepeatedField( + exception_permissions: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=4, ) - denial_condition = proto.Field( + denial_condition: expr_pb2.Expr = proto.Field( proto.MESSAGE, number=5, message=expr_pb2.Expr, diff --git a/google/cloud/iam_v2/types/policy.py b/google/cloud/iam_v2/types/policy.py index d2b8165..2f1b7f7 100644 --- a/google/cloud/iam_v2/types/policy.py +++ b/google/cloud/iam_v2/types/policy.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 @@ -61,7 +63,7 @@ class Policy(proto.Message): display_name (str): A user-specified description of the ``Policy``. This value can be up to 63 characters. - annotations (Mapping[str, str]): + annotations (MutableMapping[str, str]): A key-value map to store arbitrary metadata for the ``Policy``. Keys can be up to 63 characters. Values can be up to 255 characters. @@ -80,7 +82,7 @@ class Policy(proto.Message): delete_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time when the ``Policy`` was deleted. Empty if the policy is not deleted. - rules (Sequence[google.cloud.iam_v2.types.PolicyRule]): + rules (MutableSequence[google.cloud.iam_v2.types.PolicyRule]): A list of rules that specify the behavior of the ``Policy``. All of the rules should be of the ``kind`` specified in the ``Policy``. @@ -90,52 +92,52 @@ class Policy(proto.Message): by that authority. Usage is restricted. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - uid = proto.Field( + uid: str = proto.Field( proto.STRING, number=2, ) - kind = proto.Field( + kind: str = proto.Field( proto.STRING, number=3, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=4, ) - annotations = proto.MapField( + annotations: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=5, ) - etag = proto.Field( + etag: str = proto.Field( proto.STRING, number=6, ) - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) - update_time = proto.Field( + update_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp, ) - delete_time = proto.Field( + delete_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp, ) - rules = proto.RepeatedField( + rules: MutableSequence["PolicyRule"] = proto.RepeatedField( proto.MESSAGE, number=10, message="PolicyRule", ) - managing_authority = proto.Field( + managing_authority: str = proto.Field( proto.STRING, number=11, ) @@ -156,13 +158,13 @@ class PolicyRule(proto.Message): This value can be up to 256 characters. """ - deny_rule = proto.Field( + deny_rule: deny.DenyRule = proto.Field( proto.MESSAGE, number=2, oneof="kind", message=deny.DenyRule, ) - description = proto.Field( + description: str = proto.Field( proto.STRING, number=1, ) @@ -194,15 +196,15 @@ class ListPoliciesRequest(proto.Message): Provide this token to retrieve the next page. """ - 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, ) @@ -212,7 +214,7 @@ class ListPoliciesResponse(proto.Message): r"""Response message for ``ListPolicies``. Attributes: - policies (Sequence[google.cloud.iam_v2.types.Policy]): + policies (MutableSequence[google.cloud.iam_v2.types.Policy]): Metadata for the policies that are attached to the resource. next_page_token (str): @@ -226,12 +228,12 @@ class ListPoliciesResponse(proto.Message): def raw_page(self): return self - policies = proto.RepeatedField( + policies: MutableSequence["Policy"] = proto.RepeatedField( proto.MESSAGE, number=1, message="Policy", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -256,7 +258,7 @@ class GetPolicyRequest(proto.Message): alphanumeric or the numeric ID. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -289,16 +291,16 @@ class CreatePolicyRequest(proto.Message): first character must be a lowercase letter. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - policy = proto.Field( + policy: "Policy" = proto.Field( proto.MESSAGE, number=2, message="Policy", ) - policy_id = proto.Field( + policy_id: str = proto.Field( proto.STRING, number=3, ) @@ -317,7 +319,7 @@ class UpdatePolicyRequest(proto.Message): code and ``ABORTED`` status. """ - policy = proto.Field( + policy: "Policy" = proto.Field( proto.MESSAGE, number=1, message="Policy", @@ -350,11 +352,11 @@ class DeletePolicyRequest(proto.Message): its current ``etag``. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - etag = proto.Field( + etag: str = proto.Field( proto.STRING, number=2, ) @@ -369,7 +371,7 @@ class PolicyOperationMetadata(proto.Message): created. """ - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, diff --git a/google/cloud/iam_v2beta/__init__.py b/google/cloud/iam_v2beta/__init__.py index cc79688..f30b671 100644 --- a/google/cloud/iam_v2beta/__init__.py +++ b/google/cloud/iam_v2beta/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.iam import gapic_version as package_version + +__version__ = package_version.__version__ + from .services.policies import PoliciesAsyncClient, PoliciesClient from .types.deny import DenyRule diff --git a/google/cloud/iam_v2beta/services/policies/async_client.py b/google/cloud/iam_v2beta/services/policies/async_client.py index 05237f9..9e3b7c7 100644 --- a/google/cloud/iam_v2beta/services/policies/async_client.py +++ b/google/cloud/iam_v2beta/services/policies/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 @@ -157,9 +167,9 @@ def transport(self) -> PoliciesTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, PoliciesTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the policies client. @@ -203,11 +213,11 @@ def __init__( async def list_policies( self, - request: Union[policy.ListPoliciesRequest, dict] = None, + request: Optional[Union[policy.ListPoliciesRequest, 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.ListPoliciesAsyncPager: r"""Retrieves the policies of the specified kind that are @@ -244,7 +254,7 @@ async def sample_list_policies(): print(response) Args: - request (Union[google.cloud.iam_v2beta.types.ListPoliciesRequest, dict]): + request (Optional[Union[google.cloud.iam_v2beta.types.ListPoliciesRequest, dict]]): The request object. Request message for `ListPolicies`. parent (:class:`str`): Required. The resource that the policy is attached to, @@ -340,11 +350,11 @@ async def sample_list_policies(): async def get_policy( self, - request: Union[policy.GetPolicyRequest, dict] = None, + request: Optional[Union[policy.GetPolicyRequest, 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]] = (), ) -> policy.Policy: r"""Gets a policy. @@ -376,7 +386,7 @@ async def sample_get_policy(): print(response) Args: - request (Union[google.cloud.iam_v2beta.types.GetPolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2beta.types.GetPolicyRequest, dict]]): The request object. Request message for `GetPolicy`. name (:class:`str`): Required. The resource name of the policy to retrieve. @@ -458,13 +468,13 @@ async def sample_get_policy(): async def create_policy( self, - request: Union[gi_policy.CreatePolicyRequest, dict] = None, + request: Optional[Union[gi_policy.CreatePolicyRequest, dict]] = None, *, - parent: str = None, - policy: gi_policy.Policy = None, - policy_id: str = None, + parent: Optional[str] = None, + policy: Optional[gi_policy.Policy] = None, + policy_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 policy. @@ -500,7 +510,7 @@ async def sample_create_policy(): print(response) Args: - request (Union[google.cloud.iam_v2beta.types.CreatePolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2beta.types.CreatePolicyRequest, dict]]): The request object. Request message for `CreatePolicy`. parent (:class:`str`): Required. The resource that the policy is attached to, @@ -616,10 +626,10 @@ async def sample_create_policy(): async def update_policy( self, - request: Union[policy.UpdatePolicyRequest, dict] = None, + request: Optional[Union[policy.UpdatePolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified policy. @@ -666,7 +676,7 @@ async def sample_update_policy(): print(response) Args: - request (Union[google.cloud.iam_v2beta.types.UpdatePolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2beta.types.UpdatePolicyRequest, dict]]): The request object. Request message for `UpdatePolicy`. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -732,11 +742,11 @@ async def sample_update_policy(): async def delete_policy( self, - request: Union[policy.DeletePolicyRequest, dict] = None, + request: Optional[Union[policy.DeletePolicyRequest, 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 a policy. This action is permanent. @@ -772,7 +782,7 @@ async def sample_delete_policy(): print(response) Args: - request (Union[google.cloud.iam_v2beta.types.DeletePolicyRequest, dict]): + request (Optional[Union[google.cloud.iam_v2beta.types.DeletePolicyRequest, dict]]): The request object. Request message for `DeletePolicy`. name (:class:`str`): Required. The resource name of the policy to delete. @@ -867,10 +877,10 @@ async def sample_delete_policy(): 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/iam_v2beta/services/policies/client.py b/google/cloud/iam_v2beta/services/policies/client.py index 07f2d9d..0f8d029 100644 --- a/google/cloud/iam_v2beta/services/policies/client.py +++ b/google/cloud/iam_v2beta/services/policies/client.py @@ -16,7 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +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 @@ -62,7 +73,7 @@ class PoliciesClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[PoliciesTransport]: """Returns an appropriate transport class. @@ -317,8 +328,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, PoliciesTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, PoliciesTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the policies client. @@ -332,7 +343,7 @@ def __init__( transport (Union[str, PoliciesTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -362,6 +373,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -414,11 +426,11 @@ def __init__( def list_policies( self, - request: Union[policy.ListPoliciesRequest, dict] = None, + request: Optional[Union[policy.ListPoliciesRequest, 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.ListPoliciesPager: r"""Retrieves the policies of the specified kind that are @@ -542,11 +554,11 @@ def sample_list_policies(): def get_policy( self, - request: Union[policy.GetPolicyRequest, dict] = None, + request: Optional[Union[policy.GetPolicyRequest, 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]] = (), ) -> policy.Policy: r"""Gets a policy. @@ -651,13 +663,13 @@ def sample_get_policy(): def create_policy( self, - request: Union[gi_policy.CreatePolicyRequest, dict] = None, + request: Optional[Union[gi_policy.CreatePolicyRequest, dict]] = None, *, - parent: str = None, - policy: gi_policy.Policy = None, - policy_id: str = None, + parent: Optional[str] = None, + policy: Optional[gi_policy.Policy] = None, + policy_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 policy. @@ -800,10 +812,10 @@ def sample_create_policy(): def update_policy( self, - request: Union[policy.UpdatePolicyRequest, dict] = None, + request: Optional[Union[policy.UpdatePolicyRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Updates the specified policy. @@ -908,11 +920,11 @@ def sample_update_policy(): def delete_policy( self, - request: Union[policy.DeletePolicyRequest, dict] = None, + request: Optional[Union[policy.DeletePolicyRequest, 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 a policy. This action is permanent. @@ -1047,10 +1059,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/iam_v2beta/services/policies/transports/base.py b/google/cloud/iam_v2beta/services/policies/transports/base.py index c00cc4b..51fa09d 100644 --- a/google/cloud/iam_v2beta/services/policies/transports/base.py +++ b/google/cloud/iam_v2beta/services/policies/transports/base.py @@ -50,7 +50,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/iam_v2beta/services/policies/transports/grpc.py b/google/cloud/iam_v2beta/services/policies/transports/grpc.py index 3cd60a7..0cf30bd 100644 --- a/google/cloud/iam_v2beta/services/policies/transports/grpc.py +++ b/google/cloud/iam_v2beta/services/policies/transports/grpc.py @@ -49,14 +49,14 @@ def __init__( self, *, host: str = "iam.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, @@ -184,8 +184,8 @@ def __init__( def create_channel( cls, host: str = "iam.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/iam_v2beta/services/policies/transports/grpc_asyncio.py b/google/cloud/iam_v2beta/services/policies/transports/grpc_asyncio.py index 85ebabb..26332ed 100644 --- a/google/cloud/iam_v2beta/services/policies/transports/grpc_asyncio.py +++ b/google/cloud/iam_v2beta/services/policies/transports/grpc_asyncio.py @@ -51,7 +51,7 @@ class PoliciesGrpcAsyncIOTransport(PoliciesTransport): def create_channel( cls, host: str = "iam.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, @@ -94,15 +94,15 @@ def __init__( self, *, host: str = "iam.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/iam_v2beta/types/deny.py b/google/cloud/iam_v2beta/types/deny.py index 15f277d..24d404b 100644 --- a/google/cloud/iam_v2beta/types/deny.py +++ b/google/cloud/iam_v2beta/types/deny.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.type import expr_pb2 # type: ignore import proto # type: ignore @@ -28,7 +30,7 @@ class DenyRule(proto.Message): r"""A deny rule in an IAM deny policy. Attributes: - denied_principals (Sequence[str]): + denied_principals (MutableSequence[str]): The identities that are prevented from using one or more permissions on Google Cloud resources. This field can contain the following values: @@ -76,7 +78,7 @@ class DenyRule(proto.Message): Google Workspace or Cloud Identity customer ID. For example, ``principalSet://goog/cloudIdentityCustomerId/C01Abc35``. - exception_principals (Sequence[str]): + exception_principals (MutableSequence[str]): The identities that are excluded from the deny rule, even if they are listed in the ``denied_principals``. For example, you could add a Google group to the ``denied_principals``, @@ -86,13 +88,13 @@ class DenyRule(proto.Message): ``denied_principals`` field, excluding ``principalSet://goog/public:all``, which represents all users on the internet. - denied_permissions (Sequence[str]): + denied_permissions (MutableSequence[str]): The permissions that are explicitly denied by this rule. Each permission uses the format ``{service_fqdn}/{resource}.{verb}``, where ``{service_fqdn}`` is the fully qualified domain name for the service. For example, ``iam.googleapis.com/roles.list``. - exception_permissions (Sequence[str]): + exception_permissions (MutableSequence[str]): Specifies the permissions that this rule excludes from the set of denied permissions given by ``denied_permissions``. If a permission appears in ``denied_permissions`` *and* in @@ -115,23 +117,23 @@ class DenyRule(proto.Message): Other functions and operators are not supported. """ - denied_principals = proto.RepeatedField( + denied_principals: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=1, ) - exception_principals = proto.RepeatedField( + exception_principals: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=2, ) - denied_permissions = proto.RepeatedField( + denied_permissions: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) - exception_permissions = proto.RepeatedField( + exception_permissions: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=4, ) - denial_condition = proto.Field( + denial_condition: expr_pb2.Expr = proto.Field( proto.MESSAGE, number=5, message=expr_pb2.Expr, diff --git a/google/cloud/iam_v2beta/types/policy.py b/google/cloud/iam_v2beta/types/policy.py index 942062a..7fdf3ce 100644 --- a/google/cloud/iam_v2beta/types/policy.py +++ b/google/cloud/iam_v2beta/types/policy.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 @@ -61,7 +63,7 @@ class Policy(proto.Message): display_name (str): A user-specified description of the ``Policy``. This value can be up to 63 characters. - annotations (Mapping[str, str]): + annotations (MutableMapping[str, str]): A key-value map to store arbitrary metadata for the ``Policy``. Keys can be up to 63 characters. Values can be up to 255 characters. @@ -80,53 +82,53 @@ class Policy(proto.Message): delete_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time when the ``Policy`` was deleted. Empty if the policy is not deleted. - rules (Sequence[google.cloud.iam_v2beta.types.PolicyRule]): + rules (MutableSequence[google.cloud.iam_v2beta.types.PolicyRule]): A list of rules that specify the behavior of the ``Policy``. All of the rules should be of the ``kind`` specified in the ``Policy``. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - uid = proto.Field( + uid: str = proto.Field( proto.STRING, number=2, ) - kind = proto.Field( + kind: str = proto.Field( proto.STRING, number=3, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=4, ) - annotations = proto.MapField( + annotations: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=5, ) - etag = proto.Field( + etag: str = proto.Field( proto.STRING, number=6, ) - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp, ) - update_time = proto.Field( + update_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp, ) - delete_time = proto.Field( + delete_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp, ) - rules = proto.RepeatedField( + rules: MutableSequence["PolicyRule"] = proto.RepeatedField( proto.MESSAGE, number=10, message="PolicyRule", @@ -148,13 +150,13 @@ class PolicyRule(proto.Message): This value can be up to 256 characters. """ - deny_rule = proto.Field( + deny_rule: deny.DenyRule = proto.Field( proto.MESSAGE, number=2, oneof="kind", message=deny.DenyRule, ) - description = proto.Field( + description: str = proto.Field( proto.STRING, number=1, ) @@ -186,15 +188,15 @@ class ListPoliciesRequest(proto.Message): Provide this token to retrieve the next page. """ - 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, ) @@ -204,7 +206,7 @@ class ListPoliciesResponse(proto.Message): r"""Response message for ``ListPolicies``. Attributes: - policies (Sequence[google.cloud.iam_v2beta.types.Policy]): + policies (MutableSequence[google.cloud.iam_v2beta.types.Policy]): Metadata for the policies that are attached to the resource. next_page_token (str): @@ -218,12 +220,12 @@ class ListPoliciesResponse(proto.Message): def raw_page(self): return self - policies = proto.RepeatedField( + policies: MutableSequence["Policy"] = proto.RepeatedField( proto.MESSAGE, number=1, message="Policy", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -248,7 +250,7 @@ class GetPolicyRequest(proto.Message): alphanumeric or the numeric ID. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -281,16 +283,16 @@ class CreatePolicyRequest(proto.Message): first character must be a lowercase letter. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - policy = proto.Field( + policy: "Policy" = proto.Field( proto.MESSAGE, number=2, message="Policy", ) - policy_id = proto.Field( + policy_id: str = proto.Field( proto.STRING, number=3, ) @@ -309,7 +311,7 @@ class UpdatePolicyRequest(proto.Message): code and ``ABORTED`` status. """ - policy = proto.Field( + policy: "Policy" = proto.Field( proto.MESSAGE, number=1, message="Policy", @@ -342,11 +344,11 @@ class DeletePolicyRequest(proto.Message): its current ``etag``. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - etag = proto.Field( + etag: str = proto.Field( proto.STRING, number=2, ) @@ -361,7 +363,7 @@ class PolicyOperationMetadata(proto.Message): created. """ - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, diff --git a/owlbot.py b/owlbot.py index cb9b5e9..19601cd 100644 --- a/owlbot.py +++ b/owlbot.py @@ -12,14 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json from pathlib import Path from typing import List, Optional import shutil + import synthtool as s -from synthtool.gcp.common import CommonTemplates, detect_versions +import synthtool.gcp as gcp from synthtool.languages import python +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- + +clean_up_generated_samples = True # This is a customized version of the s.get_staging_dirs() function from synthtool to # cater for copying 2 different folders from googleapis-gen @@ -65,44 +72,29 @@ def get_staging_dirs( iam_default_version = "v2" for library in get_staging_dirs(iam_default_version, "iam"): - s.replace( - # workaround docstring formatting issues - library / "google/cloud/iam_v2/services/policies/*client.py", - """ - ``` - \{ - attachment_point: - 'cloudresourcemanager.googleapis.com%2Forganizations%2F212345678901' - filter: 'kind:denyPolicies' - \} - ```""", - """ - ``` - { - attachment_point: - 'cloudresourcemanager.googleapis.com%2Forganizations%2F212345678901' - filter: 'kind:denyPolicies' - } - ```""", - ) - s.move([library], excludes=["setup.py", "README.rst", "docs/index.rst", "google/cloud/iam/**",]) + if clean_up_generated_samples: + shutil.rmtree("samples/generated_samples", ignore_errors=True) + clean_up_generated_samples = False + s.move([library], excludes=["docs/index.rst", "**/gapic_version.py"]) for library in get_staging_dirs(iam_credentials_default_version, "iamcredentials"): - s.move([library], excludes=["setup.py", "README.rst", "docs/index.rst"]) + s.move([library], excludes=["setup.py", "docs/index.rst", "**/gapic_version.py"]) s.remove_staging_dirs() -templated_files = CommonTemplates().py_library( +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- + +templated_files = gcp.CommonTemplates().py_library( + cov_level=100, microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), ) -s.move( - [templated_files], excludes=[".coveragerc"] -) # the microgenerator has a good coveragerc file +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml", "docs/index.rst"]) python.py_samples(skip_readmes=True) -# run format nox session for all directories which have a noxfile +# run format session for all directories which have a noxfile for noxfile in Path(".").glob("**/noxfile.py"): s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) - -python.configure_previous_major_version_branches() \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..ff0dfb0 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "python", + "extra-files": [ + "google/cloud/iam/gapic_version.py", + "google/cloud/iam_credentials/gapic_version.py", + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.iam.credentials.v1.json", + "jsonpath": "$.clientLibrary.version" + }, + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.iam.v2beta.json", + "jsonpath": "$.clientLibrary.version" + }, + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.iam.v2.json", + "jsonpath": "$.clientLibrary.version" + } + ] + } + }, + "release-type": "python", + "plugins": [ + { + "type": "sentence-case" + } + ], + "initial-version": "0.1.0" +} diff --git a/samples/generated_samples/iam_v2_generated_policies_list_applicable_policies_async.py b/samples/generated_samples/iam_v2_generated_policies_list_applicable_policies_async.py deleted file mode 100644 index 86e23a3..0000000 --- a/samples/generated_samples/iam_v2_generated_policies_list_applicable_policies_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListApplicablePolicies -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-iam - - -# [START iam_v2_generated_Policies_ListApplicablePolicies_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import iam_v2 - - -async def sample_list_applicable_policies(): - # Create a client - client = iam_v2.PoliciesAsyncClient() - - # Initialize request argument(s) - request = iam_v2.ListApplicablePoliciesRequest( - attachment_point="attachment_point_value", - ) - - # Make the request - page_result = client.list_applicable_policies(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END iam_v2_generated_Policies_ListApplicablePolicies_async] diff --git a/samples/generated_samples/iam_v2_generated_policies_list_applicable_policies_sync.py b/samples/generated_samples/iam_v2_generated_policies_list_applicable_policies_sync.py deleted file mode 100644 index 655f240..0000000 --- a/samples/generated_samples/iam_v2_generated_policies_list_applicable_policies_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListApplicablePolicies -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-iam - - -# [START iam_v2_generated_Policies_ListApplicablePolicies_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import iam_v2 - - -def sample_list_applicable_policies(): - # Create a client - client = iam_v2.PoliciesClient() - - # Initialize request argument(s) - request = iam_v2.ListApplicablePoliciesRequest( - attachment_point="attachment_point_value", - ) - - # Make the request - page_result = client.list_applicable_policies(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END iam_v2_generated_Policies_ListApplicablePolicies_sync] diff --git a/samples/generated_samples/snippet_metadata_iam credentials_v1.json b/samples/generated_samples/snippet_metadata_google.iam.credentials.v1.json similarity index 97% rename from samples/generated_samples/snippet_metadata_iam credentials_v1.json rename to samples/generated_samples/snippet_metadata_google.iam.credentials.v1.json index 2f4e976..1e024f5 100644 --- a/samples/generated_samples/snippet_metadata_iam credentials_v1.json +++ b/samples/generated_samples/snippet_metadata_google.iam.credentials.v1.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-iam" + "name": "google-cloud-iam", + "version": "0.1.0" }, "snippets": [ { @@ -38,11 +39,11 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "scope", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "lifetime", @@ -130,11 +131,11 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "scope", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "lifetime", @@ -223,7 +224,7 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "audience", @@ -315,7 +316,7 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "audience", @@ -408,7 +409,7 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "payload", @@ -496,7 +497,7 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "payload", @@ -585,7 +586,7 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "payload", @@ -673,7 +674,7 @@ }, { "name": "delegates", - "type": "Sequence[str]" + "type": "MutableSequence[str]" }, { "name": "payload", diff --git a/samples/generated_samples/snippet_metadata_iam_v2.json b/samples/generated_samples/snippet_metadata_google.iam.v2.json similarity index 99% rename from samples/generated_samples/snippet_metadata_iam_v2.json rename to samples/generated_samples/snippet_metadata_google.iam.v2.json index 9cd8be2..41cce8e 100644 --- a/samples/generated_samples/snippet_metadata_iam_v2.json +++ b/samples/generated_samples/snippet_metadata_google.iam.v2.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-iam" + "name": "google-cloud-iam", + "version": "0.1.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_iam_v2beta.json b/samples/generated_samples/snippet_metadata_google.iam.v2beta.json similarity index 99% rename from samples/generated_samples/snippet_metadata_iam_v2beta.json rename to samples/generated_samples/snippet_metadata_google.iam.v2beta.json index bb12148..5c06ffb 100644 --- a/samples/generated_samples/snippet_metadata_iam_v2beta.json +++ b/samples/generated_samples/snippet_metadata_google.iam.v2beta.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-iam" + "name": "google-cloud-iam", + "version": "0.1.0" }, "snippets": [ { diff --git a/setup.py b/setup.py index befda59..58fc3ab 100644 --- a/setup.py +++ b/setup.py @@ -1,37 +1,46 @@ # -*- coding: utf-8 -*- -# -# Copyright 2018 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +# import io import os -import setuptools +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) name = "google-cloud-iam" -description = "IAM Service Account Credentials API client library" -version = "2.9.0" -# Should be one of: -# 'Development Status :: 3 - Alpha' -# 'Development Status :: 4 - Beta' -# 'Development Status :: 5 - Production/Stable' -release_status = "Development Status :: 5 - Production/Stable" + + +description = "Google Cloud Iam API client library" + +version = {} +with open(os.path.join(package_root, "google/cloud/iam/gapic_version.py")) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + dependencies = [ - "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", + "google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", "proto-plus >= 1.22.0, <2.0.0dev", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] +url = "https://github.com/googleapis/python-iam" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -57,7 +66,7 @@ author="Google LLC", author_email="googleapis-packages@google.com", license="Apache 2.0", - url="https://github.com/googleapis/python-iam", + url=url, classifiers=[ release_status, "Intended Audience :: Developers", @@ -73,11 +82,9 @@ ], platforms="Posix; MacOS X; Windows", packages=packages, + python_requires=">=3.7", namespace_packages=namespaces, install_requires=dependencies, - extras_require={"fixup": ["libcst >= 0.2.5"]}, - python_requires=">=3.7", - scripts=["scripts/fixup_iam_credentials_v1_keywords.py"], include_package_data=True, zip_safe=False, ) diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.10.txt +++ b/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.11.txt +++ b/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 5dcaa6f..6f3158c 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -1,10 +1,9 @@ # This constraints file is used to check that lower bounds # are correct in setup.py -# List *all* library dependencies and extras in this file. +# List all library dependencies and extras in this file. # Pin the version to the lower bound. -# -# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", -# Then this file should have foo==1.14.0 -google-api-core==1.32.0 +# 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 +google-api-core==1.33.2 proto-plus==1.22.0 protobuf==3.19.5 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.9.txt +++ b/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf