@@ -2601,6 +2601,283 @@ def error_code(self):
|
2601 | 2601 | # Done; return the response.
|
2602 | 2602 | return response
|
2603 | 2603 |
|
| 2604 | +def simulate_maintenance_event_unary( |
| 2605 | +self, |
| 2606 | +request: Optional[ |
| 2607 | +Union[compute.SimulateMaintenanceEventNodeGroupRequest, dict] |
| 2608 | +] = None, |
| 2609 | +*, |
| 2610 | +project: Optional[str] = None, |
| 2611 | +zone: Optional[str] = None, |
| 2612 | +node_group: Optional[str] = None, |
| 2613 | +node_groups_simulate_maintenance_event_request_resource: Optional[ |
| 2614 | +compute.NodeGroupsSimulateMaintenanceEventRequest |
| 2615 | +] = None, |
| 2616 | +retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 2617 | +timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
| 2618 | +metadata: Sequence[Tuple[str, str]] = (), |
| 2619 | +) -> compute.Operation: |
| 2620 | +r"""Simulates maintenance event on specified nodes from |
| 2621 | +the node group. |
| 2622 | +
|
| 2623 | +Args: |
| 2624 | +request (Union[google.cloud.compute_v1.types.SimulateMaintenanceEventNodeGroupRequest, dict]): |
| 2625 | +The request object. A request message for |
| 2626 | +NodeGroups.SimulateMaintenanceEvent. See the method |
| 2627 | +description for details. |
| 2628 | +project (str): |
| 2629 | +Project ID for this request. |
| 2630 | +This corresponds to the ``project`` field |
| 2631 | +on the ``request`` instance; if ``request`` is provided, this |
| 2632 | +should not be set. |
| 2633 | +zone (str): |
| 2634 | +The name of the zone for this |
| 2635 | +request. |
| 2636 | +
|
| 2637 | +This corresponds to the ``zone`` field |
| 2638 | +on the ``request`` instance; if ``request`` is provided, this |
| 2639 | +should not be set. |
| 2640 | +node_group (str): |
| 2641 | +Name of the NodeGroup resource whose |
| 2642 | +nodes will go under maintenance |
| 2643 | +simulation. |
| 2644 | +
|
| 2645 | +This corresponds to the ``node_group`` field |
| 2646 | +on the ``request`` instance; if ``request`` is provided, this |
| 2647 | +should not be set. |
| 2648 | +node_groups_simulate_maintenance_event_request_resource (google.cloud.compute_v1.types.NodeGroupsSimulateMaintenanceEventRequest): |
| 2649 | +The body resource for this request |
| 2650 | +This corresponds to the ``node_groups_simulate_maintenance_event_request_resource`` field |
| 2651 | +on the ``request`` instance; if ``request`` is provided, this |
| 2652 | +should not be set. |
| 2653 | +retry (google.api_core.retry.Retry): Designation of what errors, if any, |
| 2654 | +should be retried. |
| 2655 | +timeout (float): The timeout for this request. |
| 2656 | +metadata (Sequence[Tuple[str, str]]): Strings which should be |
| 2657 | +sent along with the request as metadata. |
| 2658 | +
|
| 2659 | +Returns: |
| 2660 | +google.api_core.extended_operation.ExtendedOperation: |
| 2661 | +An object representing a extended |
| 2662 | +long-running operation. |
| 2663 | +
|
| 2664 | +""" |
| 2665 | +# Create or coerce a protobuf request object. |
| 2666 | +# Quick check: If we got a request object, we should *not* have |
| 2667 | +# gotten any keyword arguments that map to the request. |
| 2668 | +has_flattened_params = any( |
| 2669 | +[ |
| 2670 | +project, |
| 2671 | +zone, |
| 2672 | +node_group, |
| 2673 | +node_groups_simulate_maintenance_event_request_resource, |
| 2674 | +] |
| 2675 | +) |
| 2676 | +if request is not None and has_flattened_params: |
| 2677 | +raise ValueError( |
| 2678 | +"If the `request` argument is set, then none of " |
| 2679 | +"the individual field arguments should be set." |
| 2680 | +) |
| 2681 | + |
| 2682 | +# Minor optimization to avoid making a copy if the user passes |
| 2683 | +# in a compute.SimulateMaintenanceEventNodeGroupRequest. |
| 2684 | +# There's no risk of modifying the input as we've already verified |
| 2685 | +# there are no flattened fields. |
| 2686 | +if not isinstance(request, compute.SimulateMaintenanceEventNodeGroupRequest): |
| 2687 | +request = compute.SimulateMaintenanceEventNodeGroupRequest(request) |
| 2688 | +# If we have keyword arguments corresponding to fields on the |
| 2689 | +# request, apply these. |
| 2690 | +if project is not None: |
| 2691 | +request.project = project |
| 2692 | +if zone is not None: |
| 2693 | +request.zone = zone |
| 2694 | +if node_group is not None: |
| 2695 | +request.node_group = node_group |
| 2696 | +if node_groups_simulate_maintenance_event_request_resource is not None: |
| 2697 | +request.node_groups_simulate_maintenance_event_request_resource = ( |
| 2698 | +node_groups_simulate_maintenance_event_request_resource |
| 2699 | +) |
| 2700 | + |
| 2701 | +# Wrap the RPC method; this adds retry and timeout information, |
| 2702 | +# and friendly error handling. |
| 2703 | +rpc = self._transport._wrapped_methods[ |
| 2704 | +self._transport.simulate_maintenance_event |
| 2705 | +] |
| 2706 | + |
| 2707 | +# Certain fields should be provided within the metadata header; |
| 2708 | +# add these here. |
| 2709 | +metadata = tuple(metadata) + ( |
| 2710 | +gapic_v1.routing_header.to_grpc_metadata( |
| 2711 | +( |
| 2712 | +("project", request.project), |
| 2713 | +("zone", request.zone), |
| 2714 | +("node_group", request.node_group), |
| 2715 | +) |
| 2716 | +), |
| 2717 | +) |
| 2718 | + |
| 2719 | +# Send the request. |
| 2720 | +response = rpc( |
| 2721 | +request, |
| 2722 | +retry=retry, |
| 2723 | +timeout=timeout, |
| 2724 | +metadata=metadata, |
| 2725 | +) |
| 2726 | + |
| 2727 | +# Done; return the response. |
| 2728 | +return response |
| 2729 | + |
| 2730 | +def simulate_maintenance_event( |
| 2731 | +self, |
| 2732 | +request: Optional[ |
| 2733 | +Union[compute.SimulateMaintenanceEventNodeGroupRequest, dict] |
| 2734 | +] = None, |
| 2735 | +*, |
| 2736 | +project: Optional[str] = None, |
| 2737 | +zone: Optional[str] = None, |
| 2738 | +node_group: Optional[str] = None, |
| 2739 | +node_groups_simulate_maintenance_event_request_resource: Optional[ |
| 2740 | +compute.NodeGroupsSimulateMaintenanceEventRequest |
| 2741 | +] = None, |
| 2742 | +retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 2743 | +timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
| 2744 | +metadata: Sequence[Tuple[str, str]] = (), |
| 2745 | +) -> extended_operation.ExtendedOperation: |
| 2746 | +r"""Simulates maintenance event on specified nodes from |
| 2747 | +the node group. |
| 2748 | +
|
| 2749 | +Args: |
| 2750 | +request (Union[google.cloud.compute_v1.types.SimulateMaintenanceEventNodeGroupRequest, dict]): |
| 2751 | +The request object. A request message for |
| 2752 | +NodeGroups.SimulateMaintenanceEvent. See the method |
| 2753 | +description for details. |
| 2754 | +project (str): |
| 2755 | +Project ID for this request. |
| 2756 | +This corresponds to the ``project`` field |
| 2757 | +on the ``request`` instance; if ``request`` is provided, this |
| 2758 | +should not be set. |
| 2759 | +zone (str): |
| 2760 | +The name of the zone for this |
| 2761 | +request. |
| 2762 | +
|
| 2763 | +This corresponds to the ``zone`` field |
| 2764 | +on the ``request`` instance; if ``request`` is provided, this |
| 2765 | +should not be set. |
| 2766 | +node_group (str): |
| 2767 | +Name of the NodeGroup resource whose |
| 2768 | +nodes will go under maintenance |
| 2769 | +simulation. |
| 2770 | +
|
| 2771 | +This corresponds to the ``node_group`` field |
| 2772 | +on the ``request`` instance; if ``request`` is provided, this |
| 2773 | +should not be set. |
| 2774 | +node_groups_simulate_maintenance_event_request_resource (google.cloud.compute_v1.types.NodeGroupsSimulateMaintenanceEventRequest): |
| 2775 | +The body resource for this request |
| 2776 | +This corresponds to the ``node_groups_simulate_maintenance_event_request_resource`` field |
| 2777 | +on the ``request`` instance; if ``request`` is provided, this |
| 2778 | +should not be set. |
| 2779 | +retry (google.api_core.retry.Retry): Designation of what errors, if any, |
| 2780 | +should be retried. |
| 2781 | +timeout (float): The timeout for this request. |
| 2782 | +metadata (Sequence[Tuple[str, str]]): Strings which should be |
| 2783 | +sent along with the request as metadata. |
| 2784 | +
|
| 2785 | +Returns: |
| 2786 | +google.api_core.extended_operation.ExtendedOperation: |
| 2787 | +An object representing a extended |
| 2788 | +long-running operation. |
| 2789 | +
|
| 2790 | +""" |
| 2791 | +# Create or coerce a protobuf request object. |
| 2792 | +# Quick check: If we got a request object, we should *not* have |
| 2793 | +# gotten any keyword arguments that map to the request. |
| 2794 | +has_flattened_params = any( |
| 2795 | +[ |
| 2796 | +project, |
| 2797 | +zone, |
| 2798 | +node_group, |
| 2799 | +node_groups_simulate_maintenance_event_request_resource, |
| 2800 | +] |
| 2801 | +) |
| 2802 | +if request is not None and has_flattened_params: |
| 2803 | +raise ValueError( |
| 2804 | +"If the `request` argument is set, then none of " |
| 2805 | +"the individual field arguments should be set." |
| 2806 | +) |
| 2807 | + |
| 2808 | +# Minor optimization to avoid making a copy if the user passes |
| 2809 | +# in a compute.SimulateMaintenanceEventNodeGroupRequest. |
| 2810 | +# There's no risk of modifying the input as we've already verified |
| 2811 | +# there are no flattened fields. |
| 2812 | +if not isinstance(request, compute.SimulateMaintenanceEventNodeGroupRequest): |
| 2813 | +request = compute.SimulateMaintenanceEventNodeGroupRequest(request) |
| 2814 | +# If we have keyword arguments corresponding to fields on the |
| 2815 | +# request, apply these. |
| 2816 | +if project is not None: |
| 2817 | +request.project = project |
| 2818 | +if zone is not None: |
| 2819 | +request.zone = zone |
| 2820 | +if node_group is not None: |
| 2821 | +request.node_group = node_group |
| 2822 | +if node_groups_simulate_maintenance_event_request_resource is not None: |
| 2823 | +request.node_groups_simulate_maintenance_event_request_resource = ( |
| 2824 | +node_groups_simulate_maintenance_event_request_resource |
| 2825 | +) |
| 2826 | + |
| 2827 | +# Wrap the RPC method; this adds retry and timeout information, |
| 2828 | +# and friendly error handling. |
| 2829 | +rpc = self._transport._wrapped_methods[ |
| 2830 | +self._transport.simulate_maintenance_event |
| 2831 | +] |
| 2832 | + |
| 2833 | +# Certain fields should be provided within the metadata header; |
| 2834 | +# add these here. |
| 2835 | +metadata = tuple(metadata) + ( |
| 2836 | +gapic_v1.routing_header.to_grpc_metadata( |
| 2837 | +( |
| 2838 | +("project", request.project), |
| 2839 | +("zone", request.zone), |
| 2840 | +("node_group", request.node_group), |
| 2841 | +) |
| 2842 | +), |
| 2843 | +) |
| 2844 | + |
| 2845 | +# Send the request. |
| 2846 | +response = rpc( |
| 2847 | +request, |
| 2848 | +retry=retry, |
| 2849 | +timeout=timeout, |
| 2850 | +metadata=metadata, |
| 2851 | +) |
| 2852 | + |
| 2853 | +operation_service = self._transport._zone_operations_client |
| 2854 | +operation_request = compute.GetZoneOperationRequest() |
| 2855 | +operation_request.project = request.project |
| 2856 | +operation_request.zone = request.zone |
| 2857 | +operation_request.operation = response.name |
| 2858 | + |
| 2859 | +get_operation = functools.partial(operation_service.get, operation_request) |
| 2860 | +# Cancel is not part of extended operations yet. |
| 2861 | +cancel_operation = lambda: None |
| 2862 | + |
| 2863 | +# Note: this class is an implementation detail to provide a uniform |
| 2864 | +# set of names for certain fields in the extended operation proto message. |
| 2865 | +# See google.api_core.extended_operation.ExtendedOperation for details |
| 2866 | +# on these properties and the expected interface. |
| 2867 | +class _CustomOperation(extended_operation.ExtendedOperation): |
| 2868 | +@property |
| 2869 | +def error_message(self): |
| 2870 | +return self._extended_operation.http_error_message |
| 2871 | + |
| 2872 | +@property |
| 2873 | +def error_code(self): |
| 2874 | +return self._extended_operation.http_error_status_code |
| 2875 | + |
| 2876 | +response = _CustomOperation.make(get_operation, cancel_operation, response) |
| 2877 | + |
| 2878 | +# Done; return the response. |
| 2879 | +return response |
| 2880 | + |
2604 | 2881 | def test_iam_permissions(
|
2605 | 2882 | self,
|
2606 | 2883 | request: Optional[
|
|
0 commit comments