google-cloud-cloudcontrolspartner 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/cloudcontrolspartner/__init__.py +115 -0
- google/cloud/cloudcontrolspartner/gapic_version.py +16 -0
- google/cloud/cloudcontrolspartner/py.typed +2 -0
- google/cloud/cloudcontrolspartner_v1/__init__.py +103 -0
- google/cloud/cloudcontrolspartner_v1/gapic_metadata.json +197 -0
- google/cloud/cloudcontrolspartner_v1/gapic_version.py +16 -0
- google/cloud/cloudcontrolspartner_v1/py.typed +2 -0
- google/cloud/cloudcontrolspartner_v1/services/__init__.py +15 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/__init__.py +22 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/async_client.py +1253 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/client.py +1705 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/pagers.py +429 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/__init__.py +41 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/base.py +340 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/grpc.py +466 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/grpc_asyncio.py +472 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_core/transports/rest.py +1212 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/__init__.py +22 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/async_client.py +528 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/client.py +935 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/pagers.py +155 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/__init__.py +41 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/base.py +194 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/grpc.py +300 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/grpc_asyncio.py +299 -0
- google/cloud/cloudcontrolspartner_v1/services/cloud_controls_partner_monitoring/transports/rest.py +434 -0
- google/cloud/cloudcontrolspartner_v1/types/__init__.py +82 -0
- google/cloud/cloudcontrolspartner_v1/types/access_approval_requests.py +228 -0
- google/cloud/cloudcontrolspartner_v1/types/completion_state.py +53 -0
- google/cloud/cloudcontrolspartner_v1/types/core.py +93 -0
- google/cloud/cloudcontrolspartner_v1/types/customer_workloads.py +300 -0
- google/cloud/cloudcontrolspartner_v1/types/customers.py +233 -0
- google/cloud/cloudcontrolspartner_v1/types/ekm_connections.py +141 -0
- google/cloud/cloudcontrolspartner_v1/types/monitoring.py +24 -0
- google/cloud/cloudcontrolspartner_v1/types/partner_permissions.py +94 -0
- google/cloud/cloudcontrolspartner_v1/types/partners.py +188 -0
- google/cloud/cloudcontrolspartner_v1/types/violations.py +388 -0
- google/cloud/cloudcontrolspartner_v1beta/__init__.py +103 -0
- google/cloud/cloudcontrolspartner_v1beta/gapic_metadata.json +197 -0
- google/cloud/cloudcontrolspartner_v1beta/gapic_version.py +16 -0
- google/cloud/cloudcontrolspartner_v1beta/py.typed +2 -0
- google/cloud/cloudcontrolspartner_v1beta/services/__init__.py +15 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/__init__.py +22 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/async_client.py +1262 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/client.py +1714 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/pagers.py +429 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/__init__.py +41 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/base.py +340 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/grpc.py +466 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/grpc_asyncio.py +472 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_core/transports/rest.py +1212 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/__init__.py +22 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/async_client.py +530 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/client.py +937 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/pagers.py +155 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/__init__.py +41 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/base.py +194 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/grpc.py +300 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/grpc_asyncio.py +299 -0
- google/cloud/cloudcontrolspartner_v1beta/services/cloud_controls_partner_monitoring/transports/rest.py +434 -0
- google/cloud/cloudcontrolspartner_v1beta/types/__init__.py +82 -0
- google/cloud/cloudcontrolspartner_v1beta/types/access_approval_requests.py +230 -0
- google/cloud/cloudcontrolspartner_v1beta/types/completion_state.py +53 -0
- google/cloud/cloudcontrolspartner_v1beta/types/core.py +93 -0
- google/cloud/cloudcontrolspartner_v1beta/types/customer_workloads.py +304 -0
- google/cloud/cloudcontrolspartner_v1beta/types/customers.py +236 -0
- google/cloud/cloudcontrolspartner_v1beta/types/ekm_connections.py +143 -0
- google/cloud/cloudcontrolspartner_v1beta/types/monitoring.py +24 -0
- google/cloud/cloudcontrolspartner_v1beta/types/partner_permissions.py +96 -0
- google/cloud/cloudcontrolspartner_v1beta/types/partners.py +189 -0
- google/cloud/cloudcontrolspartner_v1beta/types/violations.py +391 -0
- google_cloud_cloudcontrolspartner-0.1.0.dist-info/LICENSE +202 -0
- google_cloud_cloudcontrolspartner-0.1.0.dist-info/METADATA +137 -0
- google_cloud_cloudcontrolspartner-0.1.0.dist-info/RECORD +76 -0
- google_cloud_cloudcontrolspartner-0.1.0.dist-info/WHEEL +5 -0
- google_cloud_cloudcontrolspartner-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2023 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from typing import (
|
|
17
|
+
Any,
|
|
18
|
+
AsyncIterator,
|
|
19
|
+
Awaitable,
|
|
20
|
+
Callable,
|
|
21
|
+
Iterator,
|
|
22
|
+
Optional,
|
|
23
|
+
Sequence,
|
|
24
|
+
Tuple,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
from google.cloud.cloudcontrolspartner_v1beta.types import violations
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ListViolationsPager:
|
|
31
|
+
"""A pager for iterating through ``list_violations`` requests.
|
|
32
|
+
|
|
33
|
+
This class thinly wraps an initial
|
|
34
|
+
:class:`google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsResponse` object, and
|
|
35
|
+
provides an ``__iter__`` method to iterate through its
|
|
36
|
+
``violations`` field.
|
|
37
|
+
|
|
38
|
+
If there are more pages, the ``__iter__`` method will make additional
|
|
39
|
+
``ListViolations`` requests and continue to iterate
|
|
40
|
+
through the ``violations`` field on the
|
|
41
|
+
corresponding responses.
|
|
42
|
+
|
|
43
|
+
All the usual :class:`google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsResponse`
|
|
44
|
+
attributes are available on the pager. If multiple requests are made, only
|
|
45
|
+
the most recent response is retained, and thus used for attribute lookup.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
method: Callable[..., violations.ListViolationsResponse],
|
|
51
|
+
request: violations.ListViolationsRequest,
|
|
52
|
+
response: violations.ListViolationsResponse,
|
|
53
|
+
*,
|
|
54
|
+
metadata: Sequence[Tuple[str, str]] = ()
|
|
55
|
+
):
|
|
56
|
+
"""Instantiate the pager.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
method (Callable): The method that was originally called, and
|
|
60
|
+
which instantiated this pager.
|
|
61
|
+
request (google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsRequest):
|
|
62
|
+
The initial request object.
|
|
63
|
+
response (google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsResponse):
|
|
64
|
+
The initial response object.
|
|
65
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
66
|
+
sent along with the request as metadata.
|
|
67
|
+
"""
|
|
68
|
+
self._method = method
|
|
69
|
+
self._request = violations.ListViolationsRequest(request)
|
|
70
|
+
self._response = response
|
|
71
|
+
self._metadata = metadata
|
|
72
|
+
|
|
73
|
+
def __getattr__(self, name: str) -> Any:
|
|
74
|
+
return getattr(self._response, name)
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def pages(self) -> Iterator[violations.ListViolationsResponse]:
|
|
78
|
+
yield self._response
|
|
79
|
+
while self._response.next_page_token:
|
|
80
|
+
self._request.page_token = self._response.next_page_token
|
|
81
|
+
self._response = self._method(self._request, metadata=self._metadata)
|
|
82
|
+
yield self._response
|
|
83
|
+
|
|
84
|
+
def __iter__(self) -> Iterator[violations.Violation]:
|
|
85
|
+
for page in self.pages:
|
|
86
|
+
yield from page.violations
|
|
87
|
+
|
|
88
|
+
def __repr__(self) -> str:
|
|
89
|
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ListViolationsAsyncPager:
|
|
93
|
+
"""A pager for iterating through ``list_violations`` requests.
|
|
94
|
+
|
|
95
|
+
This class thinly wraps an initial
|
|
96
|
+
:class:`google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsResponse` object, and
|
|
97
|
+
provides an ``__aiter__`` method to iterate through its
|
|
98
|
+
``violations`` field.
|
|
99
|
+
|
|
100
|
+
If there are more pages, the ``__aiter__`` method will make additional
|
|
101
|
+
``ListViolations`` requests and continue to iterate
|
|
102
|
+
through the ``violations`` field on the
|
|
103
|
+
corresponding responses.
|
|
104
|
+
|
|
105
|
+
All the usual :class:`google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsResponse`
|
|
106
|
+
attributes are available on the pager. If multiple requests are made, only
|
|
107
|
+
the most recent response is retained, and thus used for attribute lookup.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
def __init__(
|
|
111
|
+
self,
|
|
112
|
+
method: Callable[..., Awaitable[violations.ListViolationsResponse]],
|
|
113
|
+
request: violations.ListViolationsRequest,
|
|
114
|
+
response: violations.ListViolationsResponse,
|
|
115
|
+
*,
|
|
116
|
+
metadata: Sequence[Tuple[str, str]] = ()
|
|
117
|
+
):
|
|
118
|
+
"""Instantiates the pager.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
method (Callable): The method that was originally called, and
|
|
122
|
+
which instantiated this pager.
|
|
123
|
+
request (google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsRequest):
|
|
124
|
+
The initial request object.
|
|
125
|
+
response (google.cloud.cloudcontrolspartner_v1beta.types.ListViolationsResponse):
|
|
126
|
+
The initial response object.
|
|
127
|
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
|
128
|
+
sent along with the request as metadata.
|
|
129
|
+
"""
|
|
130
|
+
self._method = method
|
|
131
|
+
self._request = violations.ListViolationsRequest(request)
|
|
132
|
+
self._response = response
|
|
133
|
+
self._metadata = metadata
|
|
134
|
+
|
|
135
|
+
def __getattr__(self, name: str) -> Any:
|
|
136
|
+
return getattr(self._response, name)
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
async def pages(self) -> AsyncIterator[violations.ListViolationsResponse]:
|
|
140
|
+
yield self._response
|
|
141
|
+
while self._response.next_page_token:
|
|
142
|
+
self._request.page_token = self._response.next_page_token
|
|
143
|
+
self._response = await self._method(self._request, metadata=self._metadata)
|
|
144
|
+
yield self._response
|
|
145
|
+
|
|
146
|
+
def __aiter__(self) -> AsyncIterator[violations.Violation]:
|
|
147
|
+
async def async_generator():
|
|
148
|
+
async for page in self.pages:
|
|
149
|
+
for response in page.violations:
|
|
150
|
+
yield response
|
|
151
|
+
|
|
152
|
+
return async_generator()
|
|
153
|
+
|
|
154
|
+
def __repr__(self) -> str:
|
|
155
|
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2023 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from collections import OrderedDict
|
|
17
|
+
from typing import Dict, Type
|
|
18
|
+
|
|
19
|
+
from .base import CloudControlsPartnerMonitoringTransport
|
|
20
|
+
from .grpc import CloudControlsPartnerMonitoringGrpcTransport
|
|
21
|
+
from .grpc_asyncio import CloudControlsPartnerMonitoringGrpcAsyncIOTransport
|
|
22
|
+
from .rest import (
|
|
23
|
+
CloudControlsPartnerMonitoringRestInterceptor,
|
|
24
|
+
CloudControlsPartnerMonitoringRestTransport,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Compile a registry of transports.
|
|
28
|
+
_transport_registry = (
|
|
29
|
+
OrderedDict()
|
|
30
|
+
) # type: Dict[str, Type[CloudControlsPartnerMonitoringTransport]]
|
|
31
|
+
_transport_registry["grpc"] = CloudControlsPartnerMonitoringGrpcTransport
|
|
32
|
+
_transport_registry["grpc_asyncio"] = CloudControlsPartnerMonitoringGrpcAsyncIOTransport
|
|
33
|
+
_transport_registry["rest"] = CloudControlsPartnerMonitoringRestTransport
|
|
34
|
+
|
|
35
|
+
__all__ = (
|
|
36
|
+
"CloudControlsPartnerMonitoringTransport",
|
|
37
|
+
"CloudControlsPartnerMonitoringGrpcTransport",
|
|
38
|
+
"CloudControlsPartnerMonitoringGrpcAsyncIOTransport",
|
|
39
|
+
"CloudControlsPartnerMonitoringRestTransport",
|
|
40
|
+
"CloudControlsPartnerMonitoringRestInterceptor",
|
|
41
|
+
)
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2023 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
import abc
|
|
17
|
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
|
18
|
+
|
|
19
|
+
import google.api_core
|
|
20
|
+
from google.api_core import exceptions as core_exceptions
|
|
21
|
+
from google.api_core import gapic_v1
|
|
22
|
+
from google.api_core import retry as retries
|
|
23
|
+
import google.auth # type: ignore
|
|
24
|
+
from google.auth import credentials as ga_credentials # type: ignore
|
|
25
|
+
from google.oauth2 import service_account # type: ignore
|
|
26
|
+
|
|
27
|
+
from google.cloud.cloudcontrolspartner_v1beta import gapic_version as package_version
|
|
28
|
+
from google.cloud.cloudcontrolspartner_v1beta.types import violations
|
|
29
|
+
|
|
30
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
31
|
+
gapic_version=package_version.__version__
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class CloudControlsPartnerMonitoringTransport(abc.ABC):
|
|
36
|
+
"""Abstract transport class for CloudControlsPartnerMonitoring."""
|
|
37
|
+
|
|
38
|
+
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
|
|
39
|
+
|
|
40
|
+
DEFAULT_HOST: str = "cloudcontrolspartner.googleapis.com"
|
|
41
|
+
|
|
42
|
+
def __init__(
|
|
43
|
+
self,
|
|
44
|
+
*,
|
|
45
|
+
host: str = DEFAULT_HOST,
|
|
46
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
47
|
+
credentials_file: Optional[str] = None,
|
|
48
|
+
scopes: Optional[Sequence[str]] = None,
|
|
49
|
+
quota_project_id: Optional[str] = None,
|
|
50
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
51
|
+
always_use_jwt_access: Optional[bool] = False,
|
|
52
|
+
api_audience: Optional[str] = None,
|
|
53
|
+
**kwargs,
|
|
54
|
+
) -> None:
|
|
55
|
+
"""Instantiate the transport.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
host (Optional[str]):
|
|
59
|
+
The hostname to connect to (default: 'cloudcontrolspartner.googleapis.com').
|
|
60
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
61
|
+
authorization credentials to attach to requests. These
|
|
62
|
+
credentials identify the application to the service; if none
|
|
63
|
+
are specified, the client will attempt to ascertain the
|
|
64
|
+
credentials from the environment.
|
|
65
|
+
credentials_file (Optional[str]): A file with credentials that can
|
|
66
|
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
|
67
|
+
This argument is mutually exclusive with credentials.
|
|
68
|
+
scopes (Optional[Sequence[str]]): A list of scopes.
|
|
69
|
+
quota_project_id (Optional[str]): An optional project to use for billing
|
|
70
|
+
and quota.
|
|
71
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
72
|
+
The client info used to send a user-agent string along with
|
|
73
|
+
API requests. If ``None``, then default info will be used.
|
|
74
|
+
Generally, you only need to set this if you're developing
|
|
75
|
+
your own client library.
|
|
76
|
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
77
|
+
be used for service account credentials.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
|
|
81
|
+
|
|
82
|
+
# Save the scopes.
|
|
83
|
+
self._scopes = scopes
|
|
84
|
+
|
|
85
|
+
# If no credentials are provided, then determine the appropriate
|
|
86
|
+
# defaults.
|
|
87
|
+
if credentials and credentials_file:
|
|
88
|
+
raise core_exceptions.DuplicateCredentialArgs(
|
|
89
|
+
"'credentials_file' and 'credentials' are mutually exclusive"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
if credentials_file is not None:
|
|
93
|
+
credentials, _ = google.auth.load_credentials_from_file(
|
|
94
|
+
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
|
|
95
|
+
)
|
|
96
|
+
elif credentials is None:
|
|
97
|
+
credentials, _ = google.auth.default(
|
|
98
|
+
**scopes_kwargs, quota_project_id=quota_project_id
|
|
99
|
+
)
|
|
100
|
+
# Don't apply audience if the credentials file passed from user.
|
|
101
|
+
if hasattr(credentials, "with_gdch_audience"):
|
|
102
|
+
credentials = credentials.with_gdch_audience(
|
|
103
|
+
api_audience if api_audience else host
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# If the credentials are service account credentials, then always try to use self signed JWT.
|
|
107
|
+
if (
|
|
108
|
+
always_use_jwt_access
|
|
109
|
+
and isinstance(credentials, service_account.Credentials)
|
|
110
|
+
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
|
|
111
|
+
):
|
|
112
|
+
credentials = credentials.with_always_use_jwt_access(True)
|
|
113
|
+
|
|
114
|
+
# Save the credentials.
|
|
115
|
+
self._credentials = credentials
|
|
116
|
+
|
|
117
|
+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
|
|
118
|
+
if ":" not in host:
|
|
119
|
+
host += ":443"
|
|
120
|
+
self._host = host
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def host(self):
|
|
124
|
+
return self._host
|
|
125
|
+
|
|
126
|
+
def _prep_wrapped_messages(self, client_info):
|
|
127
|
+
# Precompute the wrapped methods.
|
|
128
|
+
self._wrapped_methods = {
|
|
129
|
+
self.list_violations: gapic_v1.method.wrap_method(
|
|
130
|
+
self.list_violations,
|
|
131
|
+
default_retry=retries.Retry(
|
|
132
|
+
initial=1.0,
|
|
133
|
+
maximum=10.0,
|
|
134
|
+
multiplier=1.3,
|
|
135
|
+
predicate=retries.if_exception_type(
|
|
136
|
+
core_exceptions.ServiceUnavailable,
|
|
137
|
+
),
|
|
138
|
+
deadline=60.0,
|
|
139
|
+
),
|
|
140
|
+
default_timeout=60.0,
|
|
141
|
+
client_info=client_info,
|
|
142
|
+
),
|
|
143
|
+
self.get_violation: gapic_v1.method.wrap_method(
|
|
144
|
+
self.get_violation,
|
|
145
|
+
default_retry=retries.Retry(
|
|
146
|
+
initial=1.0,
|
|
147
|
+
maximum=10.0,
|
|
148
|
+
multiplier=1.3,
|
|
149
|
+
predicate=retries.if_exception_type(
|
|
150
|
+
core_exceptions.ServiceUnavailable,
|
|
151
|
+
),
|
|
152
|
+
deadline=60.0,
|
|
153
|
+
),
|
|
154
|
+
default_timeout=60.0,
|
|
155
|
+
client_info=client_info,
|
|
156
|
+
),
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
def close(self):
|
|
160
|
+
"""Closes resources associated with the transport.
|
|
161
|
+
|
|
162
|
+
.. warning::
|
|
163
|
+
Only call this method if the transport is NOT shared
|
|
164
|
+
with other clients - this may cause errors in other clients!
|
|
165
|
+
"""
|
|
166
|
+
raise NotImplementedError()
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def list_violations(
|
|
170
|
+
self,
|
|
171
|
+
) -> Callable[
|
|
172
|
+
[violations.ListViolationsRequest],
|
|
173
|
+
Union[
|
|
174
|
+
violations.ListViolationsResponse,
|
|
175
|
+
Awaitable[violations.ListViolationsResponse],
|
|
176
|
+
],
|
|
177
|
+
]:
|
|
178
|
+
raise NotImplementedError()
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def get_violation(
|
|
182
|
+
self,
|
|
183
|
+
) -> Callable[
|
|
184
|
+
[violations.GetViolationRequest],
|
|
185
|
+
Union[violations.Violation, Awaitable[violations.Violation]],
|
|
186
|
+
]:
|
|
187
|
+
raise NotImplementedError()
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def kind(self) -> str:
|
|
191
|
+
raise NotImplementedError()
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
__all__ = ("CloudControlsPartnerMonitoringTransport",)
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2023 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
|
|
17
|
+
import warnings
|
|
18
|
+
|
|
19
|
+
from google.api_core import gapic_v1, grpc_helpers
|
|
20
|
+
import google.auth # type: ignore
|
|
21
|
+
from google.auth import credentials as ga_credentials # type: ignore
|
|
22
|
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
23
|
+
import grpc # type: ignore
|
|
24
|
+
|
|
25
|
+
from google.cloud.cloudcontrolspartner_v1beta.types import violations
|
|
26
|
+
|
|
27
|
+
from .base import DEFAULT_CLIENT_INFO, CloudControlsPartnerMonitoringTransport
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class CloudControlsPartnerMonitoringGrpcTransport(
|
|
31
|
+
CloudControlsPartnerMonitoringTransport
|
|
32
|
+
):
|
|
33
|
+
"""gRPC backend transport for CloudControlsPartnerMonitoring.
|
|
34
|
+
|
|
35
|
+
Service describing handlers for resources
|
|
36
|
+
|
|
37
|
+
This class defines the same methods as the primary client, so the
|
|
38
|
+
primary client can load the underlying transport implementation
|
|
39
|
+
and call it.
|
|
40
|
+
|
|
41
|
+
It sends protocol buffers over the wire using gRPC (which is built on
|
|
42
|
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
_stubs: Dict[str, Callable]
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
*,
|
|
50
|
+
host: str = "cloudcontrolspartner.googleapis.com",
|
|
51
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
52
|
+
credentials_file: Optional[str] = None,
|
|
53
|
+
scopes: Optional[Sequence[str]] = None,
|
|
54
|
+
channel: Optional[grpc.Channel] = None,
|
|
55
|
+
api_mtls_endpoint: Optional[str] = None,
|
|
56
|
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
|
57
|
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
|
58
|
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
|
59
|
+
quota_project_id: Optional[str] = None,
|
|
60
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
61
|
+
always_use_jwt_access: Optional[bool] = False,
|
|
62
|
+
api_audience: Optional[str] = None,
|
|
63
|
+
) -> None:
|
|
64
|
+
"""Instantiate the transport.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
host (Optional[str]):
|
|
68
|
+
The hostname to connect to (default: 'cloudcontrolspartner.googleapis.com').
|
|
69
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
70
|
+
authorization credentials to attach to requests. These
|
|
71
|
+
credentials identify the application to the service; if none
|
|
72
|
+
are specified, the client will attempt to ascertain the
|
|
73
|
+
credentials from the environment.
|
|
74
|
+
This argument is ignored if ``channel`` is provided.
|
|
75
|
+
credentials_file (Optional[str]): A file with credentials that can
|
|
76
|
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
|
77
|
+
This argument is ignored if ``channel`` is provided.
|
|
78
|
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
|
79
|
+
ignored if ``channel`` is provided.
|
|
80
|
+
channel (Optional[grpc.Channel]): A ``Channel`` instance through
|
|
81
|
+
which to make calls.
|
|
82
|
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
|
83
|
+
If provided, it overrides the ``host`` argument and tries to create
|
|
84
|
+
a mutual TLS channel with client SSL credentials from
|
|
85
|
+
``client_cert_source`` or application default SSL credentials.
|
|
86
|
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
|
87
|
+
Deprecated. A callback to provide client SSL certificate bytes and
|
|
88
|
+
private key bytes, both in PEM format. It is ignored if
|
|
89
|
+
``api_mtls_endpoint`` is None.
|
|
90
|
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
|
91
|
+
for the grpc channel. It is ignored if ``channel`` is provided.
|
|
92
|
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
|
93
|
+
A callback to provide client certificate bytes and private key bytes,
|
|
94
|
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
|
95
|
+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
|
|
96
|
+
quota_project_id (Optional[str]): An optional project to use for billing
|
|
97
|
+
and quota.
|
|
98
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
99
|
+
The client info used to send a user-agent string along with
|
|
100
|
+
API requests. If ``None``, then default info will be used.
|
|
101
|
+
Generally, you only need to set this if you're developing
|
|
102
|
+
your own client library.
|
|
103
|
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
104
|
+
be used for service account credentials.
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
|
108
|
+
creation failed for any reason.
|
|
109
|
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
|
110
|
+
and ``credentials_file`` are passed.
|
|
111
|
+
"""
|
|
112
|
+
self._grpc_channel = None
|
|
113
|
+
self._ssl_channel_credentials = ssl_channel_credentials
|
|
114
|
+
self._stubs: Dict[str, Callable] = {}
|
|
115
|
+
|
|
116
|
+
if api_mtls_endpoint:
|
|
117
|
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
|
118
|
+
if client_cert_source:
|
|
119
|
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
|
120
|
+
|
|
121
|
+
if channel:
|
|
122
|
+
# Ignore credentials if a channel was passed.
|
|
123
|
+
credentials = False
|
|
124
|
+
# If a channel was explicitly provided, set it.
|
|
125
|
+
self._grpc_channel = channel
|
|
126
|
+
self._ssl_channel_credentials = None
|
|
127
|
+
|
|
128
|
+
else:
|
|
129
|
+
if api_mtls_endpoint:
|
|
130
|
+
host = api_mtls_endpoint
|
|
131
|
+
|
|
132
|
+
# Create SSL credentials with client_cert_source or application
|
|
133
|
+
# default SSL credentials.
|
|
134
|
+
if client_cert_source:
|
|
135
|
+
cert, key = client_cert_source()
|
|
136
|
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
|
137
|
+
certificate_chain=cert, private_key=key
|
|
138
|
+
)
|
|
139
|
+
else:
|
|
140
|
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
|
141
|
+
|
|
142
|
+
else:
|
|
143
|
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
|
144
|
+
cert, key = client_cert_source_for_mtls()
|
|
145
|
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
|
146
|
+
certificate_chain=cert, private_key=key
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# The base transport sets the host, credentials and scopes
|
|
150
|
+
super().__init__(
|
|
151
|
+
host=host,
|
|
152
|
+
credentials=credentials,
|
|
153
|
+
credentials_file=credentials_file,
|
|
154
|
+
scopes=scopes,
|
|
155
|
+
quota_project_id=quota_project_id,
|
|
156
|
+
client_info=client_info,
|
|
157
|
+
always_use_jwt_access=always_use_jwt_access,
|
|
158
|
+
api_audience=api_audience,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
if not self._grpc_channel:
|
|
162
|
+
self._grpc_channel = type(self).create_channel(
|
|
163
|
+
self._host,
|
|
164
|
+
# use the credentials which are saved
|
|
165
|
+
credentials=self._credentials,
|
|
166
|
+
# Set ``credentials_file`` to ``None`` here as
|
|
167
|
+
# the credentials that we saved earlier should be used.
|
|
168
|
+
credentials_file=None,
|
|
169
|
+
scopes=self._scopes,
|
|
170
|
+
ssl_credentials=self._ssl_channel_credentials,
|
|
171
|
+
quota_project_id=quota_project_id,
|
|
172
|
+
options=[
|
|
173
|
+
("grpc.max_send_message_length", -1),
|
|
174
|
+
("grpc.max_receive_message_length", -1),
|
|
175
|
+
],
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Wrap messages. This must be done after self._grpc_channel exists
|
|
179
|
+
self._prep_wrapped_messages(client_info)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def create_channel(
|
|
183
|
+
cls,
|
|
184
|
+
host: str = "cloudcontrolspartner.googleapis.com",
|
|
185
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
186
|
+
credentials_file: Optional[str] = None,
|
|
187
|
+
scopes: Optional[Sequence[str]] = None,
|
|
188
|
+
quota_project_id: Optional[str] = None,
|
|
189
|
+
**kwargs,
|
|
190
|
+
) -> grpc.Channel:
|
|
191
|
+
"""Create and return a gRPC channel object.
|
|
192
|
+
Args:
|
|
193
|
+
host (Optional[str]): The host for the channel to use.
|
|
194
|
+
credentials (Optional[~.Credentials]): The
|
|
195
|
+
authorization credentials to attach to requests. These
|
|
196
|
+
credentials identify this application to the service. If
|
|
197
|
+
none are specified, the client will attempt to ascertain
|
|
198
|
+
the credentials from the environment.
|
|
199
|
+
credentials_file (Optional[str]): A file with credentials that can
|
|
200
|
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
|
201
|
+
This argument is mutually exclusive with credentials.
|
|
202
|
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
|
203
|
+
service. These are only used when credentials are not specified and
|
|
204
|
+
are passed to :func:`google.auth.default`.
|
|
205
|
+
quota_project_id (Optional[str]): An optional project to use for billing
|
|
206
|
+
and quota.
|
|
207
|
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
|
208
|
+
channel creation.
|
|
209
|
+
Returns:
|
|
210
|
+
grpc.Channel: A gRPC channel object.
|
|
211
|
+
|
|
212
|
+
Raises:
|
|
213
|
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
|
214
|
+
and ``credentials_file`` are passed.
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
return grpc_helpers.create_channel(
|
|
218
|
+
host,
|
|
219
|
+
credentials=credentials,
|
|
220
|
+
credentials_file=credentials_file,
|
|
221
|
+
quota_project_id=quota_project_id,
|
|
222
|
+
default_scopes=cls.AUTH_SCOPES,
|
|
223
|
+
scopes=scopes,
|
|
224
|
+
default_host=cls.DEFAULT_HOST,
|
|
225
|
+
**kwargs,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
@property
|
|
229
|
+
def grpc_channel(self) -> grpc.Channel:
|
|
230
|
+
"""Return the channel designed to connect to this service."""
|
|
231
|
+
return self._grpc_channel
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def list_violations(
|
|
235
|
+
self,
|
|
236
|
+
) -> Callable[
|
|
237
|
+
[violations.ListViolationsRequest], violations.ListViolationsResponse
|
|
238
|
+
]:
|
|
239
|
+
r"""Return a callable for the list violations method over gRPC.
|
|
240
|
+
|
|
241
|
+
Lists Violations for a workload Callers may also choose to read
|
|
242
|
+
across multiple Customers or for a single customer as per
|
|
243
|
+
`AIP-159 <https://google.aip.dev/159>`__ by using '-' (the
|
|
244
|
+
hyphen or dash character) as a wildcard character instead of
|
|
245
|
+
{customer} & {workload}. Format:
|
|
246
|
+
``organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}``
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
Callable[[~.ListViolationsRequest],
|
|
250
|
+
~.ListViolationsResponse]:
|
|
251
|
+
A function that, when called, will call the underlying RPC
|
|
252
|
+
on the server.
|
|
253
|
+
"""
|
|
254
|
+
# Generate a "stub function" on-the-fly which will actually make
|
|
255
|
+
# the request.
|
|
256
|
+
# gRPC handles serialization and deserialization, so we just need
|
|
257
|
+
# to pass in the functions for each.
|
|
258
|
+
if "list_violations" not in self._stubs:
|
|
259
|
+
self._stubs["list_violations"] = self.grpc_channel.unary_unary(
|
|
260
|
+
"/google.cloud.cloudcontrolspartner.v1beta.CloudControlsPartnerMonitoring/ListViolations",
|
|
261
|
+
request_serializer=violations.ListViolationsRequest.serialize,
|
|
262
|
+
response_deserializer=violations.ListViolationsResponse.deserialize,
|
|
263
|
+
)
|
|
264
|
+
return self._stubs["list_violations"]
|
|
265
|
+
|
|
266
|
+
@property
|
|
267
|
+
def get_violation(
|
|
268
|
+
self,
|
|
269
|
+
) -> Callable[[violations.GetViolationRequest], violations.Violation]:
|
|
270
|
+
r"""Return a callable for the get violation method over gRPC.
|
|
271
|
+
|
|
272
|
+
Gets details of a single Violation.
|
|
273
|
+
|
|
274
|
+
Returns:
|
|
275
|
+
Callable[[~.GetViolationRequest],
|
|
276
|
+
~.Violation]:
|
|
277
|
+
A function that, when called, will call the underlying RPC
|
|
278
|
+
on the server.
|
|
279
|
+
"""
|
|
280
|
+
# Generate a "stub function" on-the-fly which will actually make
|
|
281
|
+
# the request.
|
|
282
|
+
# gRPC handles serialization and deserialization, so we just need
|
|
283
|
+
# to pass in the functions for each.
|
|
284
|
+
if "get_violation" not in self._stubs:
|
|
285
|
+
self._stubs["get_violation"] = self.grpc_channel.unary_unary(
|
|
286
|
+
"/google.cloud.cloudcontrolspartner.v1beta.CloudControlsPartnerMonitoring/GetViolation",
|
|
287
|
+
request_serializer=violations.GetViolationRequest.serialize,
|
|
288
|
+
response_deserializer=violations.Violation.deserialize,
|
|
289
|
+
)
|
|
290
|
+
return self._stubs["get_violation"]
|
|
291
|
+
|
|
292
|
+
def close(self):
|
|
293
|
+
self.grpc_channel.close()
|
|
294
|
+
|
|
295
|
+
@property
|
|
296
|
+
def kind(self) -> str:
|
|
297
|
+
return "grpc"
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
__all__ = ("CloudControlsPartnerMonitoringGrpcTransport",)
|