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

Commit dee08f1

Browse files
docs: add generated snippets (#79)
* chore: use gapic-generator-python 0.63.2 docs: add generated snippets PiperOrigin-RevId: 427792504 Source-Link: googleapis/googleapis@55b9e1e Source-Link: https://github.com/googleapis/googleapis-gen/commit/bf4e86b753f42cb0edb1fd51fbe840d7da0a1cde Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmY0ZTg2Yjc1M2Y0MmNiMGVkYjFmZDUxZmJlODQwZDdkYTBhMWNkZSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 27fb0c2 commit dee08f1

15 files changed

+1352
-0
lines changed

google/cloud/service_usage_v1/services/service_usage/async_client.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,29 @@ async def enable_service(
216216
r"""Enable a service so that it can be used with a
217217
project.
218218
219+
220+
.. code-block::
221+
222+
from google.cloud import service_usage_v1
223+
224+
def sample_enable_service():
225+
# Create a client
226+
client = service_usage_v1.ServiceUsageClient()
227+
228+
# Initialize request argument(s)
229+
request = service_usage_v1.EnableServiceRequest(
230+
)
231+
232+
# Make the request
233+
operation = client.enable_service(request=request)
234+
235+
print("Waiting for operation to complete...")
236+
237+
response = operation.result()
238+
239+
# Handle the response
240+
print(response)
241+
219242
Args:
220243
request (Union[google.cloud.service_usage_v1.types.EnableServiceRequest, dict]):
221244
The request object. Request message for the
@@ -284,6 +307,29 @@ async def disable_service(
284307
``FAILED_PRECONDITION`` status if the target service is not
285308
currently enabled.
286309
310+
311+
.. code-block::
312+
313+
from google.cloud import service_usage_v1
314+
315+
def sample_disable_service():
316+
# Create a client
317+
client = service_usage_v1.ServiceUsageClient()
318+
319+
# Initialize request argument(s)
320+
request = service_usage_v1.DisableServiceRequest(
321+
)
322+
323+
# Make the request
324+
operation = client.disable_service(request=request)
325+
326+
print("Waiting for operation to complete...")
327+
328+
response = operation.result()
329+
330+
# Handle the response
331+
print(response)
332+
287333
Args:
288334
request (Union[google.cloud.service_usage_v1.types.DisableServiceRequest, dict]):
289335
The request object. Request message for the
@@ -346,6 +392,25 @@ async def get_service(
346392
r"""Returns the service configuration and enabled state
347393
for a given service.
348394
395+
396+
.. code-block::
397+
398+
from google.cloud import service_usage_v1
399+
400+
def sample_get_service():
401+
# Create a client
402+
client = service_usage_v1.ServiceUsageClient()
403+
404+
# Initialize request argument(s)
405+
request = service_usage_v1.GetServiceRequest(
406+
)
407+
408+
# Make the request
409+
response = client.get_service(request=request)
410+
411+
# Handle the response
412+
print(response)
413+
349414
Args:
350415
request (Union[google.cloud.service_usage_v1.types.GetServiceRequest, dict]):
351416
The request object. Request message for the `GetService`
@@ -408,6 +473,26 @@ async def list_services(
408473
which provides higher throughput and richer filtering
409474
capability.
410475
476+
477+
.. code-block::
478+
479+
from google.cloud import service_usage_v1
480+
481+
def sample_list_services():
482+
# Create a client
483+
client = service_usage_v1.ServiceUsageClient()
484+
485+
# Initialize request argument(s)
486+
request = service_usage_v1.ListServicesRequest(
487+
)
488+
489+
# Make the request
490+
page_result = client.list_services(request=request)
491+
492+
# Handle the response
493+
for response in page_result:
494+
print(response)
495+
411496
Args:
412497
request (Union[google.cloud.service_usage_v1.types.ListServicesRequest, dict]):
413498
The request object. Request message for the
@@ -468,6 +553,29 @@ async def batch_enable_services(
468553
no state changes occur. To enable a single service, use the
469554
``EnableService`` method instead.
470555
556+
557+
.. code-block::
558+
559+
from google.cloud import service_usage_v1
560+
561+
def sample_batch_enable_services():
562+
# Create a client
563+
client = service_usage_v1.ServiceUsageClient()
564+
565+
# Initialize request argument(s)
566+
request = service_usage_v1.BatchEnableServicesRequest(
567+
)
568+
569+
# Make the request
570+
operation = client.batch_enable_services(request=request)
571+
572+
print("Waiting for operation to complete...")
573+
574+
response = operation.result()
575+
576+
# Handle the response
577+
print(response)
578+
471579
Args:
472580
request (Union[google.cloud.service_usage_v1.types.BatchEnableServicesRequest, dict]):
473581
The request object. Request message for the
@@ -530,6 +638,25 @@ async def batch_get_services(
530638
r"""Returns the service configurations and enabled states
531639
for a given list of services.
532640
641+
642+
.. code-block::
643+
644+
from google.cloud import service_usage_v1
645+
646+
def sample_batch_get_services():
647+
# Create a client
648+
client = service_usage_v1.ServiceUsageClient()
649+
650+
# Initialize request argument(s)
651+
request = service_usage_v1.BatchGetServicesRequest(
652+
)
653+
654+
# Make the request
655+
response = client.batch_get_services(request=request)
656+
657+
# Handle the response
658+
print(response)
659+
533660
Args:
534661
request (Union[google.cloud.service_usage_v1.types.BatchGetServicesRequest, dict]):
535662
The request object. Request message for the

google/cloud/service_usage_v1/services/service_usage/client.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,30 @@ def enable_service(
401401
r"""Enable a service so that it can be used with a
402402
project.
403403
404+
405+
406+
.. code-block::
407+
408+
from google.cloud import service_usage_v1
409+
410+
def sample_enable_service():
411+
# Create a client
412+
client = service_usage_v1.ServiceUsageClient()
413+
414+
# Initialize request argument(s)
415+
request = service_usage_v1.EnableServiceRequest(
416+
)
417+
418+
# Make the request
419+
operation = client.enable_service(request=request)
420+
421+
print("Waiting for operation to complete...")
422+
423+
response = operation.result()
424+
425+
# Handle the response
426+
print(response)
427+
404428
Args:
405429
request (Union[google.cloud.service_usage_v1.types.EnableServiceRequest, dict]):
406430
The request object. Request message for the
@@ -470,6 +494,30 @@ def disable_service(
470494
``FAILED_PRECONDITION`` status if the target service is not
471495
currently enabled.
472496
497+
498+
499+
.. code-block::
500+
501+
from google.cloud import service_usage_v1
502+
503+
def sample_disable_service():
504+
# Create a client
505+
client = service_usage_v1.ServiceUsageClient()
506+
507+
# Initialize request argument(s)
508+
request = service_usage_v1.DisableServiceRequest(
509+
)
510+
511+
# Make the request
512+
operation = client.disable_service(request=request)
513+
514+
print("Waiting for operation to complete...")
515+
516+
response = operation.result()
517+
518+
# Handle the response
519+
print(response)
520+
473521
Args:
474522
request (Union[google.cloud.service_usage_v1.types.DisableServiceRequest, dict]):
475523
The request object. Request message for the
@@ -533,6 +581,26 @@ def get_service(
533581
r"""Returns the service configuration and enabled state
534582
for a given service.
535583
584+
585+
586+
.. code-block::
587+
588+
from google.cloud import service_usage_v1
589+
590+
def sample_get_service():
591+
# Create a client
592+
client = service_usage_v1.ServiceUsageClient()
593+
594+
# Initialize request argument(s)
595+
request = service_usage_v1.GetServiceRequest(
596+
)
597+
598+
# Make the request
599+
response = client.get_service(request=request)
600+
601+
# Handle the response
602+
print(response)
603+
536604
Args:
537605
request (Union[google.cloud.service_usage_v1.types.GetServiceRequest, dict]):
538606
The request object. Request message for the `GetService`
@@ -596,6 +664,27 @@ def list_services(
596664
which provides higher throughput and richer filtering
597665
capability.
598666
667+
668+
669+
.. code-block::
670+
671+
from google.cloud import service_usage_v1
672+
673+
def sample_list_services():
674+
# Create a client
675+
client = service_usage_v1.ServiceUsageClient()
676+
677+
# Initialize request argument(s)
678+
request = service_usage_v1.ListServicesRequest(
679+
)
680+
681+
# Make the request
682+
page_result = client.list_services(request=request)
683+
684+
# Handle the response
685+
for response in page_result:
686+
print(response)
687+
599688
Args:
600689
request (Union[google.cloud.service_usage_v1.types.ListServicesRequest, dict]):
601690
The request object. Request message for the
@@ -657,6 +746,30 @@ def batch_enable_services(
657746
no state changes occur. To enable a single service, use the
658747
``EnableService`` method instead.
659748
749+
750+
751+
.. code-block::
752+
753+
from google.cloud import service_usage_v1
754+
755+
def sample_batch_enable_services():
756+
# Create a client
757+
client = service_usage_v1.ServiceUsageClient()
758+
759+
# Initialize request argument(s)
760+
request = service_usage_v1.BatchEnableServicesRequest(
761+
)
762+
763+
# Make the request
764+
operation = client.batch_enable_services(request=request)
765+
766+
print("Waiting for operation to complete...")
767+
768+
response = operation.result()
769+
770+
# Handle the response
771+
print(response)
772+
660773
Args:
661774
request (Union[google.cloud.service_usage_v1.types.BatchEnableServicesRequest, dict]):
662775
The request object. Request message for the
@@ -720,6 +833,26 @@ def batch_get_services(
720833
r"""Returns the service configurations and enabled states
721834
for a given list of services.
722835
836+
837+
838+
.. code-block::
839+
840+
from google.cloud import service_usage_v1
841+
842+
def sample_batch_get_services():
843+
# Create a client
844+
client = service_usage_v1.ServiceUsageClient()
845+
846+
# Initialize request argument(s)
847+
request = service_usage_v1.BatchGetServicesRequest(
848+
)
849+
850+
# Make the request
851+
response = client.batch_get_services(request=request)
852+
853+
# Handle the response
854+
print(response)
855+
723856
Args:
724857
request (Union[google.cloud.service_usage_v1.types.BatchGetServicesRequest, dict]):
725858
The request object. Request message for the
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 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+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for BatchEnableServices
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-service-usage
24+
25+
26+
# [START serviceusage_generated_service_usage_v1_ServiceUsage_BatchEnableServices_async]
27+
from google.cloud import service_usage_v1
28+
29+
30+
async def sample_batch_enable_services():
31+
# Create a client
32+
client = service_usage_v1.ServiceUsageAsyncClient()
33+
34+
# Initialize request argument(s)
35+
request = service_usage_v1.BatchEnableServicesRequest(
36+
)
37+
38+
# Make the request
39+
operation = client.batch_enable_services(request=request)
40+
41+
print("Waiting for operation to complete...")
42+
43+
response = await operation.result()
44+
45+
# Handle the response
46+
print(response)
47+
48+
# [END serviceusage_generated_service_usage_v1_ServiceUsage_BatchEnableServices_async]

0 commit comments

Comments
 (0)