Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit e2660f2

Browse files
feat: add common resource helper paths, expose client transport (#17)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/fd138ecd-79c4-4b01-b00c-a340f46edbee/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 338157137 Source-Link: googleapis/googleapis@c7331b7
1 parent fcc0f86 commit e2660f2

File tree

16 files changed

+542
-310
lines changed

16 files changed

+542
-310
lines changed

.kokoro/docs/common.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ env_vars: {
3030

3131
env_vars: {
3232
key: "V2_STAGING_BUCKET"
33-
value: "docs-staging-v2-staging"
33+
value: "docs-staging-v2"
3434
}
3535

3636
# It will upload the docker image after successful builds.

.kokoro/test-samples.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
2828
git checkout $LATEST_RELEASE
2929
fi
3030

31+
# Exit early if samples directory doesn't exist
32+
if [ ! -d "./samples" ]; then
33+
echo "No tests run. `./samples` not found"
34+
exit 0
35+
fi
36+
3137
# Disable buffering, so that the logs stream through.
3238
export PYTHONUNBUFFERED=1
3339

@@ -101,4 +107,4 @@ cd "$ROOT"
101107
# Workaround for Kokoro permissions issue: delete secrets
102108
rm testing/{test-env.sh,client-secrets.json,service-account.json}
103109

104-
exit "$RTN"
110+
exit "$RTN"

CODE_OF_CONDUCT.md

+87-36
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,95 @@
11
<!-- # Generated by synthtool. DO NOT EDIT! !-->
2-
# Contributor Code of Conduct
2+
# Code of Conduct
33

4-
As contributors and maintainers of this project,
5-
and in the interest of fostering an open and welcoming community,
6-
we pledge to respect all people who contribute through reporting issues,
7-
posting feature requests, updating documentation,
8-
submitting pull requests or patches, and other activities.
4+
## Our Pledge
95

10-
We are committed to making participation in this project
11-
a harassment-free experience for everyone,
12-
regardless of level of experience, gender, gender identity and expression,
13-
sexual orientation, disability, personal appearance,
14-
body size, race, ethnicity, age, religion, or nationality.
6+
In the interest of fostering an open and welcoming environment, we as
7+
contributors and maintainers pledge to making participation in our project and
8+
our community a harassment-free experience for everyone, regardless of age, body
9+
size, disability, ethnicity, gender identity and expression, level of
10+
experience, education, socio-economic status, nationality, personal appearance,
11+
race, religion, or sexual identity and orientation.
12+
13+
## Our Standards
14+
15+
Examples of behavior that contributes to creating a positive environment
16+
include:
17+
18+
* Using welcoming and inclusive language
19+
* Being respectful of differing viewpoints and experiences
20+
* Gracefully accepting constructive criticism
21+
* Focusing on what is best for the community
22+
* Showing empathy towards other community members
1523

1624
Examples of unacceptable behavior by participants include:
1725

18-
* The use of sexualized language or imagery
19-
* Personal attacks
20-
* Trolling or insulting/derogatory comments
21-
* Public or private harassment
22-
* Publishing other's private information,
23-
such as physical or electronic
24-
addresses, without explicit permission
25-
* Other unethical or unprofessional conduct.
26+
* The use of sexualized language or imagery and unwelcome sexual attention or
27+
advances
28+
* Trolling, insulting/derogatory comments, and personal or political attacks
29+
* Public or private harassment
30+
* Publishing others' private information, such as a physical or electronic
31+
address, without explicit permission
32+
* Other conduct which could reasonably be considered inappropriate in a
33+
professional setting
34+
35+
## Our Responsibilities
36+
37+
Project maintainers are responsible for clarifying the standards of acceptable
38+
behavior and are expected to take appropriate and fair corrective action in
39+
response to any instances of unacceptable behavior.
2640

2741
Project maintainers have the right and responsibility to remove, edit, or reject
28-
comments, commits, code, wiki edits, issues, and other contributions
29-
that are not aligned to this Code of Conduct.
30-
By adopting this Code of Conduct,
31-
project maintainers commit themselves to fairly and consistently
32-
applying these principles to every aspect of managing this project.
33-
Project maintainers who do not follow or enforce the Code of Conduct
34-
may be permanently removed from the project team.
35-
36-
This code of conduct applies both within project spaces and in public spaces
37-
when an individual is representing the project or its community.
38-
39-
Instances of abusive, harassing, or otherwise unacceptable behavior
40-
may be reported by opening an issue
41-
or contacting one or more of the project maintainers.
42-
43-
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
44-
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
42+
comments, commits, code, wiki edits, issues, and other contributions that are
43+
not aligned to this Code of Conduct, or to ban temporarily or permanently any
44+
contributor for other behaviors that they deem inappropriate, threatening,
45+
offensive, or harmful.
46+
47+
## Scope
48+
49+
This Code of Conduct applies both within project spaces and in public spaces
50+
when an individual is representing the project or its community. Examples of
51+
representing a project or community include using an official project e-mail
52+
address, posting via an official social media account, or acting as an appointed
53+
representative at an online or offline event. Representation of a project may be
54+
further defined and clarified by project maintainers.
55+
56+
This Code of Conduct also applies outside the project spaces when the Project
57+
Steward has a reasonable belief that an individual's behavior may have a
58+
negative impact on the project or its community.
59+
60+
## Conflict Resolution
61+
62+
We do not believe that all conflict is bad; healthy debate and disagreement
63+
often yield positive results. However, it is never okay to be disrespectful or
64+
to engage in behavior that violates the project’s code of conduct.
65+
66+
If you see someone violating the code of conduct, you are encouraged to address
67+
the behavior directly with those involved. Many issues can be resolved quickly
68+
and easily, and this gives people more control over the outcome of their
69+
dispute. If you are unable to resolve the matter for any reason, or if the
70+
behavior is threatening or harassing, report it. We are dedicated to providing
71+
an environment where participants feel welcome and safe.
72+
73+
74+
Reports should be directed to *[email protected]*, the
75+
Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to
76+
receive and address reported violations of the code of conduct. They will then
77+
work with a committee consisting of representatives from the Open Source
78+
Programs Office and the Google Open Source Strategy team. If for any reason you
79+
are uncomfortable reaching out to the Project Steward, please email
80+
81+
82+
We will investigate every complaint, but you may not receive a direct response.
83+
We will use our discretion in determining when and how to follow up on reported
84+
incidents, which may range from not taking action to permanent expulsion from
85+
the project and project-sponsored spaces. We will notify the accused of the
86+
report and provide them an opportunity to discuss it before any action is taken.
87+
The identity of the reporter will be omitted from the details of the report
88+
supplied to the accused. In potentially harmful situations, such as ongoing
89+
harassment or threats to anyone's safety, we may take action without notice.
90+
91+
## Attribution
92+
93+
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
94+
available at
95+
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@
349349
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
350350
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
351351
"grpc": ("https://grpc.io/grpc/python/", None),
352+
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
352353
}
353354

354355

docs/functions_v1/types.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Types for Google Cloud Functions v1 API
33

44
.. automodule:: google.cloud.functions_v1.types
55
:members:
6+
:show-inheritance:

functions-v1-py.tar.gz

Whitespace-only changes.

google/cloud/functions_v1/services/cloud_functions_service/async_client.py

+50-5
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,49 @@ class CloudFunctionsServiceAsyncClient:
5959
CloudFunctionsServiceClient.parse_cloud_function_path
6060
)
6161

62+
common_billing_account_path = staticmethod(
63+
CloudFunctionsServiceClient.common_billing_account_path
64+
)
65+
parse_common_billing_account_path = staticmethod(
66+
CloudFunctionsServiceClient.parse_common_billing_account_path
67+
)
68+
69+
common_folder_path = staticmethod(CloudFunctionsServiceClient.common_folder_path)
70+
parse_common_folder_path = staticmethod(
71+
CloudFunctionsServiceClient.parse_common_folder_path
72+
)
73+
74+
common_organization_path = staticmethod(
75+
CloudFunctionsServiceClient.common_organization_path
76+
)
77+
parse_common_organization_path = staticmethod(
78+
CloudFunctionsServiceClient.parse_common_organization_path
79+
)
80+
81+
common_project_path = staticmethod(CloudFunctionsServiceClient.common_project_path)
82+
parse_common_project_path = staticmethod(
83+
CloudFunctionsServiceClient.parse_common_project_path
84+
)
85+
86+
common_location_path = staticmethod(
87+
CloudFunctionsServiceClient.common_location_path
88+
)
89+
parse_common_location_path = staticmethod(
90+
CloudFunctionsServiceClient.parse_common_location_path
91+
)
92+
6293
from_service_account_file = CloudFunctionsServiceClient.from_service_account_file
6394
from_service_account_json = from_service_account_file
6495

96+
@property
97+
def transport(self) -> CloudFunctionsServiceTransport:
98+
"""Return the transport used by the client instance.
99+
100+
Returns:
101+
CloudFunctionsServiceTransport: The transport used by the client instance.
102+
"""
103+
return self._client.transport
104+
65105
get_transport_class = functools.partial(
66106
type(CloudFunctionsServiceClient).get_transport_class,
67107
type(CloudFunctionsServiceClient),
@@ -215,7 +255,8 @@ async def get_function(
215255
# Create or coerce a protobuf request object.
216256
# Sanity check: If we got a request object, we should *not* have
217257
# gotten any keyword arguments that map to the request.
218-
if request is not None and any([name]):
258+
has_flattened_params = any([name])
259+
if request is not None and has_flattened_params:
219260
raise ValueError(
220261
"If the `request` argument is set, then none of "
221262
"the individual field arguments should be set."
@@ -300,7 +341,8 @@ async def create_function(
300341
# Create or coerce a protobuf request object.
301342
# Sanity check: If we got a request object, we should *not* have
302343
# gotten any keyword arguments that map to the request.
303-
if request is not None and any([location, function]):
344+
has_flattened_params = any([location, function])
345+
if request is not None and has_flattened_params:
304346
raise ValueError(
305347
"If the `request` argument is set, then none of "
306348
"the individual field arguments should be set."
@@ -386,7 +428,8 @@ async def update_function(
386428
# Create or coerce a protobuf request object.
387429
# Sanity check: If we got a request object, we should *not* have
388430
# gotten any keyword arguments that map to the request.
389-
if request is not None and any([function]):
431+
has_flattened_params = any([function])
432+
if request is not None and has_flattened_params:
390433
raise ValueError(
391434
"If the `request` argument is set, then none of "
392435
"the individual field arguments should be set."
@@ -485,7 +528,8 @@ async def delete_function(
485528
# Create or coerce a protobuf request object.
486529
# Sanity check: If we got a request object, we should *not* have
487530
# gotten any keyword arguments that map to the request.
488-
if request is not None and any([name]):
531+
has_flattened_params = any([name])
532+
if request is not None and has_flattened_params:
489533
raise ValueError(
490534
"If the `request` argument is set, then none of "
491535
"the individual field arguments should be set."
@@ -572,7 +616,8 @@ async def call_function(
572616
# Create or coerce a protobuf request object.
573617
# Sanity check: If we got a request object, we should *not* have
574618
# gotten any keyword arguments that map to the request.
575-
if request is not None and any([name, data]):
619+
has_flattened_params = any([name, data])
620+
if request is not None and has_flattened_params:
576621
raise ValueError(
577622
"If the `request` argument is set, then none of "
578623
"the individual field arguments should be set."

google/cloud/functions_v1/services/cloud_functions_service/client.py

+72-4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
142142

143143
from_service_account_json = from_service_account_file
144144

145+
@property
146+
def transport(self) -> CloudFunctionsServiceTransport:
147+
"""Return the transport used by the client instance.
148+
149+
Returns:
150+
CloudFunctionsServiceTransport: The transport used by the client instance.
151+
"""
152+
return self._transport
153+
145154
@staticmethod
146155
def cloud_function_path(project: str, location: str, function: str,) -> str:
147156
"""Return a fully-qualified cloud_function string."""
@@ -158,6 +167,65 @@ def parse_cloud_function_path(path: str) -> Dict[str, str]:
158167
)
159168
return m.groupdict() if m else {}
160169

170+
@staticmethod
171+
def common_billing_account_path(billing_account: str,) -> str:
172+
"""Return a fully-qualified billing_account string."""
173+
return "billingAccounts/{billing_account}".format(
174+
billing_account=billing_account,
175+
)
176+
177+
@staticmethod
178+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
179+
"""Parse a billing_account path into its component segments."""
180+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
181+
return m.groupdict() if m else {}
182+
183+
@staticmethod
184+
def common_folder_path(folder: str,) -> str:
185+
"""Return a fully-qualified folder string."""
186+
return "folders/{folder}".format(folder=folder,)
187+
188+
@staticmethod
189+
def parse_common_folder_path(path: str) -> Dict[str, str]:
190+
"""Parse a folder path into its component segments."""
191+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
192+
return m.groupdict() if m else {}
193+
194+
@staticmethod
195+
def common_organization_path(organization: str,) -> str:
196+
"""Return a fully-qualified organization string."""
197+
return "organizations/{organization}".format(organization=organization,)
198+
199+
@staticmethod
200+
def parse_common_organization_path(path: str) -> Dict[str, str]:
201+
"""Parse a organization path into its component segments."""
202+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
203+
return m.groupdict() if m else {}
204+
205+
@staticmethod
206+
def common_project_path(project: str,) -> str:
207+
"""Return a fully-qualified project string."""
208+
return "projects/{project}".format(project=project,)
209+
210+
@staticmethod
211+
def parse_common_project_path(path: str) -> Dict[str, str]:
212+
"""Parse a project path into its component segments."""
213+
m = re.match(r"^projects/(?P<project>.+?)$", path)
214+
return m.groupdict() if m else {}
215+
216+
@staticmethod
217+
def common_location_path(project: str, location: str,) -> str:
218+
"""Return a fully-qualified location string."""
219+
return "projects/{project}/locations/{location}".format(
220+
project=project, location=location,
221+
)
222+
223+
@staticmethod
224+
def parse_common_location_path(path: str) -> Dict[str, str]:
225+
"""Parse a location path into its component segments."""
226+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
227+
return m.groupdict() if m else {}
228+
161229
def __init__(
162230
self,
163231
*,
@@ -193,10 +261,10 @@ def __init__(
193261
not provided, the default SSL client certificate will be used if
194262
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
195263
set, no client certificate will be used.
196-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
197-
The client info used to send a user-agent string along with
198-
API requests. If ``None``, then default info will be used.
199-
Generally, you only need to set this if you're developing
264+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
265+
The client info used to send a user-agent string along with
266+
API requests. If ``None``, then default info will be used.
267+
Generally, you only need to set this if you're developing
200268
your own client library.
201269
202270
Raises:

0 commit comments

Comments
 (0)