Skip to content

Commit 6e19333

Browse files
docs: add generated snippets (#342)
* chore: use gapic-generator-python 0.63.2 docs: add generated snippets PiperOrigin-RevId: 427792504 Source-Link: googleapis/googleapis@55b9e1e Source-Link: googleapis/googleapis-gen@bf4e86b 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 e421c05 commit 6e19333

73 files changed

Lines changed: 7264 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/google-cloud-dataproc/google/cloud/dataproc_v1/services/autoscaling_policy_service/async_client.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,31 @@ async def create_autoscaling_policy(
227227
) -> autoscaling_policies.AutoscalingPolicy:
228228
r"""Creates new autoscaling policy.
229229
230+
.. code-block::
231+
232+
from google.cloud import dataproc_v1
233+
234+
def sample_create_autoscaling_policy():
235+
# Create a client
236+
client = dataproc_v1.AutoscalingPolicyServiceClient()
237+
238+
# Initialize request argument(s)
239+
policy = dataproc_v1.AutoscalingPolicy()
240+
policy.basic_algorithm.yarn_config.scale_up_factor = 0.1578
241+
policy.basic_algorithm.yarn_config.scale_down_factor = 0.1789
242+
policy.worker_config.max_instances = 1389
243+
244+
request = dataproc_v1.CreateAutoscalingPolicyRequest(
245+
parent="parent_value",
246+
policy=policy,
247+
)
248+
249+
# Make the request
250+
response = client.create_autoscaling_policy(request=request)
251+
252+
# Handle the response
253+
print(response)
254+
230255
Args:
231256
request (Union[google.cloud.dataproc_v1.types.CreateAutoscalingPolicyRequest, dict]):
232257
The request object. A request to create an autoscaling
@@ -323,6 +348,31 @@ async def update_autoscaling_policy(
323348
Disabled check for update_mask, because all updates will be full
324349
replacements.
325350
351+
352+
.. code-block::
353+
354+
from google.cloud import dataproc_v1
355+
356+
def sample_update_autoscaling_policy():
357+
# Create a client
358+
client = dataproc_v1.AutoscalingPolicyServiceClient()
359+
360+
# Initialize request argument(s)
361+
policy = dataproc_v1.AutoscalingPolicy()
362+
policy.basic_algorithm.yarn_config.scale_up_factor = 0.1578
363+
policy.basic_algorithm.yarn_config.scale_down_factor = 0.1789
364+
policy.worker_config.max_instances = 1389
365+
366+
request = dataproc_v1.UpdateAutoscalingPolicyRequest(
367+
policy=policy,
368+
)
369+
370+
# Make the request
371+
response = client.update_autoscaling_policy(request=request)
372+
373+
# Handle the response
374+
print(response)
375+
326376
Args:
327377
request (Union[google.cloud.dataproc_v1.types.UpdateAutoscalingPolicyRequest, dict]):
328378
The request object. A request to update an autoscaling
@@ -406,6 +456,25 @@ async def get_autoscaling_policy(
406456
) -> autoscaling_policies.AutoscalingPolicy:
407457
r"""Retrieves autoscaling policy.
408458
459+
.. code-block::
460+
461+
from google.cloud import dataproc_v1
462+
463+
def sample_get_autoscaling_policy():
464+
# Create a client
465+
client = dataproc_v1.AutoscalingPolicyServiceClient()
466+
467+
# Initialize request argument(s)
468+
request = dataproc_v1.GetAutoscalingPolicyRequest(
469+
name="name_value",
470+
)
471+
472+
# Make the request
473+
response = client.get_autoscaling_policy(request=request)
474+
475+
# Handle the response
476+
print(response)
477+
409478
Args:
410479
request (Union[google.cloud.dataproc_v1.types.GetAutoscalingPolicyRequest, dict]):
411480
The request object. A request to fetch an autoscaling
@@ -499,6 +568,26 @@ async def list_autoscaling_policies(
499568
) -> pagers.ListAutoscalingPoliciesAsyncPager:
500569
r"""Lists autoscaling policies in the project.
501570
571+
.. code-block::
572+
573+
from google.cloud import dataproc_v1
574+
575+
def sample_list_autoscaling_policies():
576+
# Create a client
577+
client = dataproc_v1.AutoscalingPolicyServiceClient()
578+
579+
# Initialize request argument(s)
580+
request = dataproc_v1.ListAutoscalingPoliciesRequest(
581+
parent="parent_value",
582+
)
583+
584+
# Make the request
585+
page_result = client.list_autoscaling_policies(request=request)
586+
587+
# Handle the response
588+
for response in page_result:
589+
print(response)
590+
502591
Args:
503592
request (Union[google.cloud.dataproc_v1.types.ListAutoscalingPoliciesRequest, dict]):
504593
The request object. A request to list autoscaling
@@ -603,6 +692,23 @@ async def delete_autoscaling_policy(
603692
delete an autoscaling policy that is in use by one or
604693
more clusters.
605694
695+
696+
.. code-block::
697+
698+
from google.cloud import dataproc_v1
699+
700+
def sample_delete_autoscaling_policy():
701+
# Create a client
702+
client = dataproc_v1.AutoscalingPolicyServiceClient()
703+
704+
# Initialize request argument(s)
705+
request = dataproc_v1.DeleteAutoscalingPolicyRequest(
706+
name="name_value",
707+
)
708+
709+
# Make the request
710+
client.delete_autoscaling_policy(request=request)
711+
606712
Args:
607713
request (Union[google.cloud.dataproc_v1.types.DeleteAutoscalingPolicyRequest, dict]):
608714
The request object. A request to delete an autoscaling

packages/google-cloud-dataproc/google/cloud/dataproc_v1/services/autoscaling_policy_service/client.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,32 @@ def create_autoscaling_policy(
419419
) -> autoscaling_policies.AutoscalingPolicy:
420420
r"""Creates new autoscaling policy.
421421
422+
423+
.. code-block::
424+
425+
from google.cloud import dataproc_v1
426+
427+
def sample_create_autoscaling_policy():
428+
# Create a client
429+
client = dataproc_v1.AutoscalingPolicyServiceClient()
430+
431+
# Initialize request argument(s)
432+
policy = dataproc_v1.AutoscalingPolicy()
433+
policy.basic_algorithm.yarn_config.scale_up_factor = 0.1578
434+
policy.basic_algorithm.yarn_config.scale_down_factor = 0.1789
435+
policy.worker_config.max_instances = 1389
436+
437+
request = dataproc_v1.CreateAutoscalingPolicyRequest(
438+
parent="parent_value",
439+
policy=policy,
440+
)
441+
442+
# Make the request
443+
response = client.create_autoscaling_policy(request=request)
444+
445+
# Handle the response
446+
print(response)
447+
422448
Args:
423449
request (Union[google.cloud.dataproc_v1.types.CreateAutoscalingPolicyRequest, dict]):
424450
The request object. A request to create an autoscaling
@@ -517,6 +543,32 @@ def update_autoscaling_policy(
517543
Disabled check for update_mask, because all updates will be full
518544
replacements.
519545
546+
547+
548+
.. code-block::
549+
550+
from google.cloud import dataproc_v1
551+
552+
def sample_update_autoscaling_policy():
553+
# Create a client
554+
client = dataproc_v1.AutoscalingPolicyServiceClient()
555+
556+
# Initialize request argument(s)
557+
policy = dataproc_v1.AutoscalingPolicy()
558+
policy.basic_algorithm.yarn_config.scale_up_factor = 0.1578
559+
policy.basic_algorithm.yarn_config.scale_down_factor = 0.1789
560+
policy.worker_config.max_instances = 1389
561+
562+
request = dataproc_v1.UpdateAutoscalingPolicyRequest(
563+
policy=policy,
564+
)
565+
566+
# Make the request
567+
response = client.update_autoscaling_policy(request=request)
568+
569+
# Handle the response
570+
print(response)
571+
520572
Args:
521573
request (Union[google.cloud.dataproc_v1.types.UpdateAutoscalingPolicyRequest, dict]):
522574
The request object. A request to update an autoscaling
@@ -592,6 +644,26 @@ def get_autoscaling_policy(
592644
) -> autoscaling_policies.AutoscalingPolicy:
593645
r"""Retrieves autoscaling policy.
594646
647+
648+
.. code-block::
649+
650+
from google.cloud import dataproc_v1
651+
652+
def sample_get_autoscaling_policy():
653+
# Create a client
654+
client = dataproc_v1.AutoscalingPolicyServiceClient()
655+
656+
# Initialize request argument(s)
657+
request = dataproc_v1.GetAutoscalingPolicyRequest(
658+
name="name_value",
659+
)
660+
661+
# Make the request
662+
response = client.get_autoscaling_policy(request=request)
663+
664+
# Handle the response
665+
print(response)
666+
595667
Args:
596668
request (Union[google.cloud.dataproc_v1.types.GetAutoscalingPolicyRequest, dict]):
597669
The request object. A request to fetch an autoscaling
@@ -675,6 +747,27 @@ def list_autoscaling_policies(
675747
) -> pagers.ListAutoscalingPoliciesPager:
676748
r"""Lists autoscaling policies in the project.
677749
750+
751+
.. code-block::
752+
753+
from google.cloud import dataproc_v1
754+
755+
def sample_list_autoscaling_policies():
756+
# Create a client
757+
client = dataproc_v1.AutoscalingPolicyServiceClient()
758+
759+
# Initialize request argument(s)
760+
request = dataproc_v1.ListAutoscalingPoliciesRequest(
761+
parent="parent_value",
762+
)
763+
764+
# Make the request
765+
page_result = client.list_autoscaling_policies(request=request)
766+
767+
# Handle the response
768+
for response in page_result:
769+
print(response)
770+
678771
Args:
679772
request (Union[google.cloud.dataproc_v1.types.ListAutoscalingPoliciesRequest, dict]):
680773
The request object. A request to list autoscaling
@@ -771,6 +864,24 @@ def delete_autoscaling_policy(
771864
delete an autoscaling policy that is in use by one or
772865
more clusters.
773866
867+
868+
869+
.. code-block::
870+
871+
from google.cloud import dataproc_v1
872+
873+
def sample_delete_autoscaling_policy():
874+
# Create a client
875+
client = dataproc_v1.AutoscalingPolicyServiceClient()
876+
877+
# Initialize request argument(s)
878+
request = dataproc_v1.DeleteAutoscalingPolicyRequest(
879+
name="name_value",
880+
)
881+
882+
# Make the request
883+
client.delete_autoscaling_policy(request=request)
884+
774885
Args:
775886
request (Union[google.cloud.dataproc_v1.types.DeleteAutoscalingPolicyRequest, dict]):
776887
The request object. A request to delete an autoscaling

packages/google-cloud-dataproc/google/cloud/dataproc_v1/services/batch_controller/async_client.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,34 @@ async def create_batch(
223223
r"""Creates a batch workload that executes
224224
asynchronously.
225225
226+
227+
.. code-block::
228+
229+
from google.cloud import dataproc_v1
230+
231+
def sample_create_batch():
232+
# Create a client
233+
client = dataproc_v1.BatchControllerClient()
234+
235+
# Initialize request argument(s)
236+
batch = dataproc_v1.Batch()
237+
batch.pyspark_batch.main_python_file_uri = "main_python_file_uri_value"
238+
239+
request = dataproc_v1.CreateBatchRequest(
240+
parent="parent_value",
241+
batch=batch,
242+
)
243+
244+
# Make the request
245+
operation = client.create_batch(request=request)
246+
247+
print("Waiting for operation to complete...")
248+
249+
response = operation.result()
250+
251+
# Handle the response
252+
print(response)
253+
226254
Args:
227255
request (Union[google.cloud.dataproc_v1.types.CreateBatchRequest, dict]):
228256
The request object. A request to create a batch
@@ -324,6 +352,25 @@ async def get_batch(
324352
) -> batches.Batch:
325353
r"""Gets the batch workload resource representation.
326354
355+
.. code-block::
356+
357+
from google.cloud import dataproc_v1
358+
359+
def sample_get_batch():
360+
# Create a client
361+
client = dataproc_v1.BatchControllerClient()
362+
363+
# Initialize request argument(s)
364+
request = dataproc_v1.GetBatchRequest(
365+
name="name_value",
366+
)
367+
368+
# Make the request
369+
response = client.get_batch(request=request)
370+
371+
# Handle the response
372+
print(response)
373+
327374
Args:
328375
request (Union[google.cloud.dataproc_v1.types.GetBatchRequest, dict]):
329376
The request object. A request to get the resource
@@ -395,6 +442,26 @@ async def list_batches(
395442
) -> pagers.ListBatchesAsyncPager:
396443
r"""Lists batch workloads.
397444
445+
.. code-block::
446+
447+
from google.cloud import dataproc_v1
448+
449+
def sample_list_batches():
450+
# Create a client
451+
client = dataproc_v1.BatchControllerClient()
452+
453+
# Initialize request argument(s)
454+
request = dataproc_v1.ListBatchesRequest(
455+
parent="parent_value",
456+
)
457+
458+
# Make the request
459+
page_result = client.list_batches(request=request)
460+
461+
# Handle the response
462+
for response in page_result:
463+
print(response)
464+
398465
Args:
399466
request (Union[google.cloud.dataproc_v1.types.ListBatchesRequest, dict]):
400467
The request object. A request to list batch workloads in
@@ -476,6 +543,23 @@ async def delete_batch(
476543
terminal state, the delete fails and the response returns
477544
``FAILED_PRECONDITION``.
478545
546+
547+
.. code-block::
548+
549+
from google.cloud import dataproc_v1
550+
551+
def sample_delete_batch():
552+
# Create a client
553+
client = dataproc_v1.BatchControllerClient()
554+
555+
# Initialize request argument(s)
556+
request = dataproc_v1.DeleteBatchRequest(
557+
name="name_value",
558+
)
559+
560+
# Make the request
561+
client.delete_batch(request=request)
562+
479563
Args:
480564
request (Union[google.cloud.dataproc_v1.types.DeleteBatchRequest, dict]):
481565
The request object. A request to delete a batch

0 commit comments

Comments
 (0)