1# coding: utf-8
2# Copyright (c) 2016, 2021, Oracle and/or its affiliates.  All rights reserved.
3# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
4
5import oci  # noqa: F401
6from oci.util import WAIT_RESOURCE_NOT_FOUND  # noqa: F401
7
8
9class ComputeManagementClientCompositeOperations(object):
10    """
11    This class provides a wrapper around :py:class:`~oci.core.ComputeManagementClient` and offers convenience methods
12    for operations that would otherwise need to be chained together. For example, instead of performing an action
13    on a resource (e.g. launching an instance, creating a load balancer) and then using a waiter to wait for the resource
14    to enter a given state, you can call a single method in this class to accomplish the same functionality
15    """
16
17    def __init__(self, client, work_request_client=None, **kwargs):
18        """
19        Creates a new ComputeManagementClientCompositeOperations object
20
21        :param ComputeManagementClient client:
22            The service client which will be wrapped by this object
23
24        :param oci.work_requests.WorkRequestClient work_request_client: (optional)
25            The work request service client which will be used to wait for work request states. Default is None.
26        """
27        self.client = client
28        self._work_request_client = work_request_client if work_request_client else oci.work_requests.WorkRequestClient(self.client._config, **self.client._kwargs)
29
30    def attach_instance_pool_instance_and_wait_for_work_request(self, instance_pool_id, attach_instance_pool_instance_details, work_request_states=[], operation_kwargs={}, waiter_kwargs={}):
31        """
32        Calls :py:func:`~oci.core.ComputeManagementClient.attach_instance_pool_instance` and waits for the oci.work_requests.models.WorkRequest
33        to enter the given state(s).
34
35        :param str instance_pool_id: (required)
36            The `OCID`__ of the instance pool.
37
38            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
39
40        :param oci.core.models.AttachInstancePoolInstanceDetails attach_instance_pool_instance_details: (required)
41            Attach an instance to a pool
42
43        :param list[str] work_request_states: (optional)
44            An array of work requests states to wait on. These should be valid values for :py:attr:`~oci.work_requests.models.WorkRequest.status`
45            Default values are termination states: [STATUS_SUCCEEDED, STATUS_FAILED, STATUS_CANCELED]
46
47        :param dict operation_kwargs:
48            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.attach_instance_pool_instance`
49
50        :param dict waiter_kwargs:
51            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
52            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
53        """
54        operation_result = self.client.attach_instance_pool_instance(instance_pool_id, attach_instance_pool_instance_details, **operation_kwargs)
55        work_request_states = work_request_states if work_request_states else oci.waiter._WORK_REQUEST_TERMINATION_STATES
56        lowered_work_request_states = [w.lower() for w in work_request_states]
57        work_request_id = operation_result.headers['opc-work-request-id']
58
59        try:
60            waiter_result = oci.wait_until(
61                self._work_request_client,
62                self._work_request_client.get_work_request(work_request_id),
63                evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_work_request_states,
64                **waiter_kwargs
65            )
66            return waiter_result
67        except Exception as e:
68            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
69
70    def attach_instance_pool_instance_and_wait_for_state(self, instance_pool_id, attach_instance_pool_instance_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
71        """
72        Calls :py:func:`~oci.core.ComputeManagementClient.attach_instance_pool_instance` and waits for the :py:class:`~oci.core.models.InstancePoolInstance` acted upon
73        to enter the given state(s).
74
75        :param str instance_pool_id: (required)
76            The `OCID`__ of the instance pool.
77
78            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
79
80        :param oci.core.models.AttachInstancePoolInstanceDetails attach_instance_pool_instance_details: (required)
81            Attach an instance to a pool
82
83        :param list[str] wait_for_states:
84            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePoolInstance.lifecycle_state`
85
86        :param dict operation_kwargs:
87            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.attach_instance_pool_instance`
88
89        :param dict waiter_kwargs:
90            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
91            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
92        """
93        operation_result = self.client.attach_instance_pool_instance(instance_pool_id, attach_instance_pool_instance_details, **operation_kwargs)
94        if not wait_for_states:
95            return operation_result
96
97        lowered_wait_for_states = [w.lower() for w in wait_for_states]
98        wait_for_resource_id = operation_result.data.id
99
100        try:
101            waiter_result = oci.wait_until(
102                self.client,
103                self.client.get_instance_pool_instance(wait_for_resource_id),
104                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
105                **waiter_kwargs
106            )
107            result_to_return = waiter_result
108
109            return result_to_return
110        except Exception as e:
111            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
112
113    def attach_load_balancer_and_wait_for_state(self, instance_pool_id, attach_load_balancer_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
114        """
115        Calls :py:func:`~oci.core.ComputeManagementClient.attach_load_balancer` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
116        to enter the given state(s).
117
118        :param str instance_pool_id: (required)
119            The `OCID`__ of the instance pool.
120
121            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
122
123        :param oci.core.models.AttachLoadBalancerDetails attach_load_balancer_details: (required)
124            Load balancer being attached
125
126        :param list[str] wait_for_states:
127            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
128
129        :param dict operation_kwargs:
130            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.attach_load_balancer`
131
132        :param dict waiter_kwargs:
133            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
134            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
135        """
136        operation_result = self.client.attach_load_balancer(instance_pool_id, attach_load_balancer_details, **operation_kwargs)
137        if not wait_for_states:
138            return operation_result
139
140        lowered_wait_for_states = [w.lower() for w in wait_for_states]
141        wait_for_resource_id = operation_result.data.id
142
143        try:
144            waiter_result = oci.wait_until(
145                self.client,
146                self.client.get_instance_pool(wait_for_resource_id),
147                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
148                **waiter_kwargs
149            )
150            result_to_return = waiter_result
151
152            return result_to_return
153        except Exception as e:
154            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
155
156    def create_cluster_network_and_wait_for_work_request(self, create_cluster_network_details, work_request_states=[], operation_kwargs={}, waiter_kwargs={}):
157        """
158        Calls :py:func:`~oci.core.ComputeManagementClient.create_cluster_network` and waits for the oci.work_requests.models.WorkRequest
159        to enter the given state(s).
160
161        :param oci.core.models.CreateClusterNetworkDetails create_cluster_network_details: (required)
162            Cluster network creation details
163
164        :param list[str] work_request_states: (optional)
165            An array of work requests states to wait on. These should be valid values for :py:attr:`~oci.work_requests.models.WorkRequest.status`
166            Default values are termination states: [STATUS_SUCCEEDED, STATUS_FAILED, STATUS_CANCELED]
167
168        :param dict operation_kwargs:
169            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.create_cluster_network`
170
171        :param dict waiter_kwargs:
172            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
173            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
174        """
175        operation_result = self.client.create_cluster_network(create_cluster_network_details, **operation_kwargs)
176        work_request_states = work_request_states if work_request_states else oci.waiter._WORK_REQUEST_TERMINATION_STATES
177        lowered_work_request_states = [w.lower() for w in work_request_states]
178        work_request_id = operation_result.headers['opc-work-request-id']
179
180        try:
181            waiter_result = oci.wait_until(
182                self._work_request_client,
183                self._work_request_client.get_work_request(work_request_id),
184                evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_work_request_states,
185                **waiter_kwargs
186            )
187            return waiter_result
188        except Exception as e:
189            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
190
191    def create_cluster_network_and_wait_for_state(self, create_cluster_network_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
192        """
193        Calls :py:func:`~oci.core.ComputeManagementClient.create_cluster_network` and waits for the :py:class:`~oci.core.models.ClusterNetwork` acted upon
194        to enter the given state(s).
195
196        :param oci.core.models.CreateClusterNetworkDetails create_cluster_network_details: (required)
197            Cluster network creation details
198
199        :param list[str] wait_for_states:
200            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.ClusterNetwork.lifecycle_state`
201
202        :param dict operation_kwargs:
203            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.create_cluster_network`
204
205        :param dict waiter_kwargs:
206            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
207            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
208        """
209        operation_result = self.client.create_cluster_network(create_cluster_network_details, **operation_kwargs)
210        if not wait_for_states:
211            return operation_result
212
213        lowered_wait_for_states = [w.lower() for w in wait_for_states]
214        wait_for_resource_id = operation_result.data.id
215
216        try:
217            waiter_result = oci.wait_until(
218                self.client,
219                self.client.get_cluster_network(wait_for_resource_id),
220                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
221                **waiter_kwargs
222            )
223            result_to_return = waiter_result
224
225            return result_to_return
226        except Exception as e:
227            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
228
229    def create_instance_pool_and_wait_for_state(self, create_instance_pool_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
230        """
231        Calls :py:func:`~oci.core.ComputeManagementClient.create_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
232        to enter the given state(s).
233
234        :param oci.core.models.CreateInstancePoolDetails create_instance_pool_details: (required)
235            Instance pool creation details
236
237        :param list[str] wait_for_states:
238            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
239
240        :param dict operation_kwargs:
241            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.create_instance_pool`
242
243        :param dict waiter_kwargs:
244            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
245            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
246        """
247        operation_result = self.client.create_instance_pool(create_instance_pool_details, **operation_kwargs)
248        if not wait_for_states:
249            return operation_result
250
251        lowered_wait_for_states = [w.lower() for w in wait_for_states]
252        wait_for_resource_id = operation_result.data.id
253
254        try:
255            waiter_result = oci.wait_until(
256                self.client,
257                self.client.get_instance_pool(wait_for_resource_id),
258                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
259                **waiter_kwargs
260            )
261            result_to_return = waiter_result
262
263            return result_to_return
264        except Exception as e:
265            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
266
267    def detach_instance_pool_instance_and_wait_for_work_request(self, instance_pool_id, detach_instance_pool_instance_details, work_request_states=[], operation_kwargs={}, waiter_kwargs={}):
268        """
269        Calls :py:func:`~oci.core.ComputeManagementClient.detach_instance_pool_instance` and waits for the oci.work_requests.models.WorkRequest
270        to enter the given state(s).
271
272        :param str instance_pool_id: (required)
273            The `OCID`__ of the instance pool.
274
275            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
276
277        :param oci.core.models.DetachInstancePoolInstanceDetails detach_instance_pool_instance_details: (required)
278            Instance being detached
279
280        :param list[str] work_request_states: (optional)
281            An array of work requests states to wait on. These should be valid values for :py:attr:`~oci.work_requests.models.WorkRequest.status`
282            Default values are termination states: [STATUS_SUCCEEDED, STATUS_FAILED, STATUS_CANCELED]
283
284        :param dict operation_kwargs:
285            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.detach_instance_pool_instance`
286
287        :param dict waiter_kwargs:
288            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
289            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
290        """
291        operation_result = self.client.detach_instance_pool_instance(instance_pool_id, detach_instance_pool_instance_details, **operation_kwargs)
292        work_request_states = work_request_states if work_request_states else oci.waiter._WORK_REQUEST_TERMINATION_STATES
293        lowered_work_request_states = [w.lower() for w in work_request_states]
294        work_request_id = operation_result.headers['opc-work-request-id']
295
296        try:
297            waiter_result = oci.wait_until(
298                self._work_request_client,
299                self._work_request_client.get_work_request(work_request_id),
300                evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_work_request_states,
301                **waiter_kwargs
302            )
303            return waiter_result
304        except Exception as e:
305            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
306
307    def detach_load_balancer_and_wait_for_state(self, instance_pool_id, detach_load_balancer_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
308        """
309        Calls :py:func:`~oci.core.ComputeManagementClient.detach_load_balancer` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
310        to enter the given state(s).
311
312        :param str instance_pool_id: (required)
313            The `OCID`__ of the instance pool.
314
315            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
316
317        :param oci.core.models.DetachLoadBalancerDetails detach_load_balancer_details: (required)
318            Load balancer being detached
319
320        :param list[str] wait_for_states:
321            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
322
323        :param dict operation_kwargs:
324            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.detach_load_balancer`
325
326        :param dict waiter_kwargs:
327            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
328            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
329        """
330        operation_result = self.client.detach_load_balancer(instance_pool_id, detach_load_balancer_details, **operation_kwargs)
331        if not wait_for_states:
332            return operation_result
333
334        lowered_wait_for_states = [w.lower() for w in wait_for_states]
335        wait_for_resource_id = operation_result.data.id
336
337        try:
338            waiter_result = oci.wait_until(
339                self.client,
340                self.client.get_instance_pool(wait_for_resource_id),
341                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
342                **waiter_kwargs
343            )
344            result_to_return = waiter_result
345
346            return result_to_return
347        except Exception as e:
348            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
349
350    def launch_instance_configuration_and_wait_for_work_request(self, instance_configuration_id, instance_configuration, work_request_states=[], operation_kwargs={}, waiter_kwargs={}):
351        """
352        Calls :py:func:`~oci.core.ComputeManagementClient.launch_instance_configuration` and waits for the oci.work_requests.models.WorkRequest
353        to enter the given state(s).
354
355        :param str instance_configuration_id: (required)
356            The OCID of the instance configuration.
357
358        :param oci.core.models.InstanceConfigurationInstanceDetails instance_configuration: (required)
359            Instance configuration Instance Details
360
361        :param list[str] work_request_states: (optional)
362            An array of work requests states to wait on. These should be valid values for :py:attr:`~oci.work_requests.models.WorkRequest.status`
363            Default values are termination states: [STATUS_SUCCEEDED, STATUS_FAILED, STATUS_CANCELED]
364
365        :param dict operation_kwargs:
366            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.launch_instance_configuration`
367
368        :param dict waiter_kwargs:
369            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
370            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
371        """
372        operation_result = self.client.launch_instance_configuration(instance_configuration_id, instance_configuration, **operation_kwargs)
373        work_request_states = work_request_states if work_request_states else oci.waiter._WORK_REQUEST_TERMINATION_STATES
374        lowered_work_request_states = [w.lower() for w in work_request_states]
375        work_request_id = operation_result.headers['opc-work-request-id']
376
377        try:
378            waiter_result = oci.wait_until(
379                self._work_request_client,
380                self._work_request_client.get_work_request(work_request_id),
381                evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_work_request_states,
382                **waiter_kwargs
383            )
384            return waiter_result
385        except Exception as e:
386            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
387
388    def reset_instance_pool_and_wait_for_state(self, instance_pool_id, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
389        """
390        Calls :py:func:`~oci.core.ComputeManagementClient.reset_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
391        to enter the given state(s).
392
393        :param str instance_pool_id: (required)
394            The `OCID`__ of the instance pool.
395
396            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
397
398        :param list[str] wait_for_states:
399            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
400
401        :param dict operation_kwargs:
402            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.reset_instance_pool`
403
404        :param dict waiter_kwargs:
405            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
406            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
407        """
408        operation_result = self.client.reset_instance_pool(instance_pool_id, **operation_kwargs)
409        if not wait_for_states:
410            return operation_result
411
412        lowered_wait_for_states = [w.lower() for w in wait_for_states]
413        wait_for_resource_id = operation_result.data.id
414
415        try:
416            waiter_result = oci.wait_until(
417                self.client,
418                self.client.get_instance_pool(wait_for_resource_id),
419                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
420                **waiter_kwargs
421            )
422            result_to_return = waiter_result
423
424            return result_to_return
425        except Exception as e:
426            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
427
428    def softreset_instance_pool_and_wait_for_state(self, instance_pool_id, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
429        """
430        Calls :py:func:`~oci.core.ComputeManagementClient.softreset_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
431        to enter the given state(s).
432
433        :param str instance_pool_id: (required)
434            The `OCID`__ of the instance pool.
435
436            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
437
438        :param list[str] wait_for_states:
439            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
440
441        :param dict operation_kwargs:
442            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.softreset_instance_pool`
443
444        :param dict waiter_kwargs:
445            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
446            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
447        """
448        operation_result = self.client.softreset_instance_pool(instance_pool_id, **operation_kwargs)
449        if not wait_for_states:
450            return operation_result
451
452        lowered_wait_for_states = [w.lower() for w in wait_for_states]
453        wait_for_resource_id = operation_result.data.id
454
455        try:
456            waiter_result = oci.wait_until(
457                self.client,
458                self.client.get_instance_pool(wait_for_resource_id),
459                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
460                **waiter_kwargs
461            )
462            result_to_return = waiter_result
463
464            return result_to_return
465        except Exception as e:
466            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
467
468    def start_instance_pool_and_wait_for_state(self, instance_pool_id, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
469        """
470        Calls :py:func:`~oci.core.ComputeManagementClient.start_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
471        to enter the given state(s).
472
473        :param str instance_pool_id: (required)
474            The `OCID`__ of the instance pool.
475
476            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
477
478        :param list[str] wait_for_states:
479            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
480
481        :param dict operation_kwargs:
482            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.start_instance_pool`
483
484        :param dict waiter_kwargs:
485            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
486            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
487        """
488        operation_result = self.client.start_instance_pool(instance_pool_id, **operation_kwargs)
489        if not wait_for_states:
490            return operation_result
491
492        lowered_wait_for_states = [w.lower() for w in wait_for_states]
493        wait_for_resource_id = operation_result.data.id
494
495        try:
496            waiter_result = oci.wait_until(
497                self.client,
498                self.client.get_instance_pool(wait_for_resource_id),
499                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
500                **waiter_kwargs
501            )
502            result_to_return = waiter_result
503
504            return result_to_return
505        except Exception as e:
506            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
507
508    def stop_instance_pool_and_wait_for_state(self, instance_pool_id, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
509        """
510        Calls :py:func:`~oci.core.ComputeManagementClient.stop_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
511        to enter the given state(s).
512
513        :param str instance_pool_id: (required)
514            The `OCID`__ of the instance pool.
515
516            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
517
518        :param list[str] wait_for_states:
519            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
520
521        :param dict operation_kwargs:
522            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.stop_instance_pool`
523
524        :param dict waiter_kwargs:
525            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
526            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
527        """
528        operation_result = self.client.stop_instance_pool(instance_pool_id, **operation_kwargs)
529        if not wait_for_states:
530            return operation_result
531
532        lowered_wait_for_states = [w.lower() for w in wait_for_states]
533        wait_for_resource_id = operation_result.data.id
534
535        try:
536            waiter_result = oci.wait_until(
537                self.client,
538                self.client.get_instance_pool(wait_for_resource_id),
539                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
540                **waiter_kwargs
541            )
542            result_to_return = waiter_result
543
544            return result_to_return
545        except Exception as e:
546            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
547
548    def terminate_cluster_network_and_wait_for_work_request(self, cluster_network_id, work_request_states=[], operation_kwargs={}, waiter_kwargs={}):
549        """
550        Calls :py:func:`~oci.core.ComputeManagementClient.terminate_cluster_network` and waits for the oci.work_requests.models.WorkRequest
551        to enter the given state(s).
552
553        :param str cluster_network_id: (required)
554            The `OCID`__ of the cluster network.
555
556            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
557
558        :param list[str] work_request_states: (optional)
559            An array of work requests states to wait on. These should be valid values for :py:attr:`~oci.work_requests.models.WorkRequest.status`
560            Default values are termination states: [STATUS_SUCCEEDED, STATUS_FAILED, STATUS_CANCELED]
561
562        :param dict operation_kwargs:
563            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.terminate_cluster_network`
564
565        :param dict waiter_kwargs:
566            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
567            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
568        """
569        operation_result = self.client.terminate_cluster_network(cluster_network_id, **operation_kwargs)
570        work_request_states = work_request_states if work_request_states else oci.waiter._WORK_REQUEST_TERMINATION_STATES
571        lowered_work_request_states = [w.lower() for w in work_request_states]
572        work_request_id = operation_result.headers['opc-work-request-id']
573
574        try:
575            waiter_result = oci.wait_until(
576                self._work_request_client,
577                self._work_request_client.get_work_request(work_request_id),
578                evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_work_request_states,
579                **waiter_kwargs
580            )
581            return waiter_result
582        except Exception as e:
583            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
584
585    def terminate_instance_pool_and_wait_for_state(self, instance_pool_id, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
586        """
587        Calls :py:func:`~oci.core.ComputeManagementClient.terminate_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
588        to enter the given state(s).
589
590        :param str instance_pool_id: (required)
591            The `OCID`__ of the instance pool.
592
593            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
594
595        :param list[str] wait_for_states:
596            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
597
598        :param dict operation_kwargs:
599            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.terminate_instance_pool`
600
601        :param dict waiter_kwargs:
602            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
603            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
604        """
605        initial_get_result = self.client.get_instance_pool(instance_pool_id)
606        operation_result = None
607        try:
608            operation_result = self.client.terminate_instance_pool(instance_pool_id, **operation_kwargs)
609        except oci.exceptions.ServiceError as e:
610            if e.status == 404:
611                return WAIT_RESOURCE_NOT_FOUND
612            else:
613                raise e
614
615        if not wait_for_states:
616            return operation_result
617
618        lowered_wait_for_states = [w.lower() for w in wait_for_states]
619
620        try:
621            waiter_result = oci.wait_until(
622                self.client,
623                initial_get_result,
624                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
625                succeed_on_not_found=True,
626                **waiter_kwargs
627            )
628            result_to_return = waiter_result
629
630            return result_to_return
631        except Exception as e:
632            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
633
634    def update_cluster_network_and_wait_for_state(self, cluster_network_id, update_cluster_network_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
635        """
636        Calls :py:func:`~oci.core.ComputeManagementClient.update_cluster_network` and waits for the :py:class:`~oci.core.models.ClusterNetwork` acted upon
637        to enter the given state(s).
638
639        :param str cluster_network_id: (required)
640            The `OCID`__ of the cluster network.
641
642            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
643
644        :param oci.core.models.UpdateClusterNetworkDetails update_cluster_network_details: (required)
645            Update cluster network
646
647        :param list[str] wait_for_states:
648            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.ClusterNetwork.lifecycle_state`
649
650        :param dict operation_kwargs:
651            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.update_cluster_network`
652
653        :param dict waiter_kwargs:
654            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
655            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
656        """
657        operation_result = self.client.update_cluster_network(cluster_network_id, update_cluster_network_details, **operation_kwargs)
658        if not wait_for_states:
659            return operation_result
660
661        lowered_wait_for_states = [w.lower() for w in wait_for_states]
662        wait_for_resource_id = operation_result.data.id
663
664        try:
665            waiter_result = oci.wait_until(
666                self.client,
667                self.client.get_cluster_network(wait_for_resource_id),
668                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
669                **waiter_kwargs
670            )
671            result_to_return = waiter_result
672
673            return result_to_return
674        except Exception as e:
675            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
676
677    def update_instance_pool_and_wait_for_state(self, instance_pool_id, update_instance_pool_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
678        """
679        Calls :py:func:`~oci.core.ComputeManagementClient.update_instance_pool` and waits for the :py:class:`~oci.core.models.InstancePool` acted upon
680        to enter the given state(s).
681
682        :param str instance_pool_id: (required)
683            The `OCID`__ of the instance pool.
684
685            __ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
686
687        :param oci.core.models.UpdateInstancePoolDetails update_instance_pool_details: (required)
688            Update instance pool configuration
689
690        :param list[str] wait_for_states:
691            An array of states to wait on. These should be valid values for :py:attr:`~oci.core.models.InstancePool.lifecycle_state`
692
693        :param dict operation_kwargs:
694            A dictionary of keyword arguments to pass to :py:func:`~oci.core.ComputeManagementClient.update_instance_pool`
695
696        :param dict waiter_kwargs:
697            A dictionary of keyword arguments to pass to the :py:func:`oci.wait_until` function. For example, you could pass ``max_interval_seconds`` or ``max_interval_seconds``
698            as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
699        """
700        operation_result = self.client.update_instance_pool(instance_pool_id, update_instance_pool_details, **operation_kwargs)
701        if not wait_for_states:
702            return operation_result
703
704        lowered_wait_for_states = [w.lower() for w in wait_for_states]
705        wait_for_resource_id = operation_result.data.id
706
707        try:
708            waiter_result = oci.wait_until(
709                self.client,
710                self.client.get_instance_pool(wait_for_resource_id),
711                evaluate_response=lambda r: getattr(r.data, 'lifecycle_state') and getattr(r.data, 'lifecycle_state').lower() in lowered_wait_for_states,
712                **waiter_kwargs
713            )
714            result_to_return = waiter_result
715
716            return result_to_return
717        except Exception as e:
718            raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
719