Skip to content

Commit

Permalink
chore: use gapic-generator-python 0.53.4 (#99)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Nov 1, 2021
1 parent 6704725 commit 1d6e752
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 147 deletions.
46 changes: 24 additions & 22 deletions google/cloud/orgpolicy_v2/services/org_policy/async_client.py
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.orgpolicy_v2.services.org_policy import pagers
from google.cloud.orgpolicy_v2.types import constraint
from google.cloud.orgpolicy_v2.types import orgpolicy
Expand Down Expand Up @@ -182,18 +184,18 @@ def __init__(

async def list_constraints(
self,
request: orgpolicy.ListConstraintsRequest = None,
request: Union[orgpolicy.ListConstraintsRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListConstraintsAsyncPager:
r"""Lists ``Constraints`` that could be applied on the specified
resource.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.ListConstraintsRequest`):
request (Union[google.cloud.orgpolicy_v2.types.ListConstraintsRequest, dict]):
The request object. The request sent to the
[ListConstraints]
[google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints]
Expand Down Expand Up @@ -281,18 +283,18 @@ async def list_constraints(

async def list_policies(
self,
request: orgpolicy.ListPoliciesRequest = None,
request: Union[orgpolicy.ListPoliciesRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListPoliciesAsyncPager:
r"""Retrieves all of the ``Policies`` that exist on a particular
resource.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.ListPoliciesRequest`):
request (Union[google.cloud.orgpolicy_v2.types.ListPoliciesRequest, dict]):
The request object. The request sent to the
[ListPolicies]
[google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies]
Expand Down Expand Up @@ -382,10 +384,10 @@ async def list_policies(

async def get_policy(
self,
request: orgpolicy.GetPolicyRequest = None,
request: Union[orgpolicy.GetPolicyRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand All @@ -396,7 +398,7 @@ async def get_policy(
a ``Policy`` during read-modify-write.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.GetPolicyRequest`):
request (Union[google.cloud.orgpolicy_v2.types.GetPolicyRequest, dict]):
The request object. The request sent to the [GetPolicy]
[google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method.
name (:class:`str`):
Expand Down Expand Up @@ -467,10 +469,10 @@ async def get_policy(

async def get_effective_policy(
self,
request: orgpolicy.GetEffectivePolicyRequest = None,
request: Union[orgpolicy.GetEffectivePolicyRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand All @@ -482,7 +484,7 @@ async def get_effective_policy(
hierarchy with 'under:' prefix will not be expanded.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.GetEffectivePolicyRequest`):
request (Union[google.cloud.orgpolicy_v2.types.GetEffectivePolicyRequest, dict]):
The request object. The request sent to the
[GetEffectivePolicy]
[google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy]
Expand Down Expand Up @@ -555,11 +557,11 @@ async def get_effective_policy(

async def create_policy(
self,
request: orgpolicy.CreatePolicyRequest = None,
request: Union[orgpolicy.CreatePolicyRequest, dict] = None,
*,
parent: str = None,
policy: orgpolicy.Policy = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand All @@ -572,7 +574,7 @@ async def create_policy(
on the given Cloud resource.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.CreatePolicyRequest`):
request (Union[google.cloud.orgpolicy_v2.types.CreatePolicyRequest, dict]):
The request object. The request sent to the
[CreatePolicyRequest]
[google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy]
Expand Down Expand Up @@ -657,10 +659,10 @@ async def create_policy(

async def update_policy(
self,
request: orgpolicy.UpdatePolicyRequest = None,
request: Union[orgpolicy.UpdatePolicyRequest, dict] = None,
*,
policy: orgpolicy.Policy = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand All @@ -676,7 +678,7 @@ async def update_policy(
fields.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.UpdatePolicyRequest`):
request (Union[google.cloud.orgpolicy_v2.types.UpdatePolicyRequest, dict]):
The request object. The request sent to the
[UpdatePolicyRequest]
[google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy]
Expand Down Expand Up @@ -749,10 +751,10 @@ async def update_policy(

async def delete_policy(
self,
request: orgpolicy.DeletePolicyRequest = None,
request: Union[orgpolicy.DeletePolicyRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
Expand All @@ -763,7 +765,7 @@ async def delete_policy(
does not exist.
Args:
request (:class:`google.cloud.orgpolicy_v2.types.DeletePolicyRequest`):
request (Union[google.cloud.orgpolicy_v2.types.DeletePolicyRequest, dict]):
The request object. The request sent to the
[DeletePolicy]
[google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy]
Expand Down
16 changes: 9 additions & 7 deletions google/cloud/orgpolicy_v2/services/org_policy/client.py
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.cloud.orgpolicy_v2.services.org_policy import pagers
from google.cloud.orgpolicy_v2.types import constraint
from google.cloud.orgpolicy_v2.types import orgpolicy
Expand Down Expand Up @@ -385,7 +387,7 @@ def list_constraints(
request: Union[orgpolicy.ListConstraintsRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListConstraintsPager:
Expand Down Expand Up @@ -474,7 +476,7 @@ def list_policies(
request: Union[orgpolicy.ListPoliciesRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListPoliciesPager:
Expand Down Expand Up @@ -565,7 +567,7 @@ def get_policy(
request: Union[orgpolicy.GetPolicyRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand Down Expand Up @@ -640,7 +642,7 @@ def get_effective_policy(
request: Union[orgpolicy.GetEffectivePolicyRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand Down Expand Up @@ -719,7 +721,7 @@ def create_policy(
*,
parent: str = None,
policy: orgpolicy.Policy = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand Down Expand Up @@ -810,7 +812,7 @@ def update_policy(
request: Union[orgpolicy.UpdatePolicyRequest, dict] = None,
*,
policy: orgpolicy.Policy = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> orgpolicy.Policy:
Expand Down Expand Up @@ -892,7 +894,7 @@ def delete_policy(
request: Union[orgpolicy.DeletePolicyRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
Expand Down
35 changes: 1 addition & 34 deletions google/cloud/orgpolicy_v2/services/org_policy/transports/base.py
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -38,15 +37,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class OrgPolicyTransport(abc.ABC):
"""Abstract transport class for OrgPolicy."""
Expand Down Expand Up @@ -96,7 +86,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -129,29 +119,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down
Expand Up @@ -20,7 +20,6 @@
from google.api_core import grpc_helpers_async # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down
9 changes: 9 additions & 0 deletions google/cloud/orgpolicy_v2/types/constraint.py
Expand Up @@ -40,6 +40,13 @@ class Constraint(proto.Message):
is used in the absence of a ``policy`` being defined or inherited
for the resource in question.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
name (str):
Immutable. The resource name of the Constraint. Must be in
Expand All @@ -65,9 +72,11 @@ class Constraint(proto.Message):
list_constraint (google.cloud.orgpolicy_v2.types.Constraint.ListConstraint):
Defines this constraint as being a
ListConstraint.
This field is a member of `oneof`_ ``constraint_type``.
boolean_constraint (google.cloud.orgpolicy_v2.types.Constraint.BooleanConstraint):
Defines this constraint as being a
BooleanConstraint.
This field is a member of `oneof`_ ``constraint_type``.
"""

class ConstraintDefault(proto.Enum):
Expand Down
11 changes: 11 additions & 0 deletions google/cloud/orgpolicy_v2/types/orgpolicy.py
Expand Up @@ -150,23 +150,34 @@ class PolicySpec(proto.Message):
class PolicyRule(proto.Message):
r"""A rule used to express this policy.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
values (google.cloud.orgpolicy_v2.types.PolicySpec.PolicyRule.StringValues):
List of values to be used for this
PolicyRule. This field can be set only in
Policies for list constraints.
This field is a member of `oneof`_ ``kind``.
allow_all (bool):
Setting this to true means that all values
are allowed. This field can be set only in
Policies for list constraints.
This field is a member of `oneof`_ ``kind``.
deny_all (bool):
Setting this to true means that all values
are denied. This field can be set only in
Policies for list constraints.
This field is a member of `oneof`_ ``kind``.
enforce (bool):
If ``true``, then the ``Policy`` is enforced. If ``false``,
then any configuration is acceptable. This field can be set
only in Policies for boolean constraints.
This field is a member of `oneof`_ ``kind``.
condition (google.type.expr_pb2.Expr):
A condition which determines whether this rule is used in
the evaluation of the policy. When set, the ``expression``
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -44,9 +44,8 @@
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
# Until this issue is closed
# https://github.com/googleapis/google-cloud-python/issues/10566
"google-api-core[grpc] >= 1.26.0, <3.0.0dev",
"google-api-core[grpc] >= 1.28.0, <3.0.0dev",
"proto-plus >= 1.10.0",
"packaging >= 14.3",
),
python_requires=">=3.6",
classifiers=[
Expand Down
3 changes: 1 addition & 2 deletions testing/constraints-3.6.txt
Expand Up @@ -19,6 +19,5 @@
#
# 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.26.0
google-api-core==1.28.0
proto-plus==1.10.0
packaging==14.3

0 comments on commit 1d6e752

Please sign in to comment.