Skip to content

Commit aa281ff

Browse files
authored
Merge pull request #200 from oracle/release_2019-12-18
Releasing version 2.8.0
2 parents 26f6325 + 5e0c164 commit aa281ff

File tree

143 files changed

+37710
-0
lines changed

Some content is hidden

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

143 files changed

+37710
-0
lines changed

src/oci/apigateway/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# coding: utf-8
2+
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3+
4+
from __future__ import absolute_import
5+
6+
7+
from .deployment_client import DeploymentClient
8+
from .deployment_client_composite_operations import DeploymentClientCompositeOperations
9+
from .gateway_client import GatewayClient
10+
from .gateway_client_composite_operations import GatewayClientCompositeOperations
11+
from .work_requests_client import WorkRequestsClient
12+
from .work_requests_client_composite_operations import WorkRequestsClientCompositeOperations
13+
from . import models
14+
15+
__all__ = ["DeploymentClient", "DeploymentClientCompositeOperations", "GatewayClient", "GatewayClientCompositeOperations", "WorkRequestsClient", "WorkRequestsClientCompositeOperations", "models"]

src/oci/apigateway/deployment_client.py

Lines changed: 628 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# coding: utf-8
2+
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3+
4+
import oci # noqa: F401
5+
from oci.util import WAIT_RESOURCE_NOT_FOUND # noqa: F401
6+
7+
8+
class DeploymentClientCompositeOperations(object):
9+
"""
10+
This class provides a wrapper around :py:class:`~oci.apigateway.DeploymentClient` and offers convenience methods
11+
for operations that would otherwise need to be chained together. For example, instead of performing an action
12+
on a resource (e.g. launching an instance, creating a load balancer) and then using a waiter to wait for the resource
13+
to enter a given state, you can call a single method in this class to accomplish the same functionality
14+
"""
15+
16+
def __init__(self, client, **kwargs):
17+
"""
18+
Creates a new DeploymentClientCompositeOperations object
19+
20+
:param DeploymentClient client:
21+
The service client which will be wrapped by this object
22+
"""
23+
self.client = client
24+
25+
def change_deployment_compartment_and_wait_for_state(self, deployment_id, change_deployment_compartment_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
26+
"""
27+
Calls :py:func:`~oci.apigateway.DeploymentClient.change_deployment_compartment` and waits for the :py:class:`~oci.apigateway.models.WorkRequest`
28+
to enter the given state(s).
29+
30+
:param str deployment_id: (required)
31+
The ocid of the deployment.
32+
33+
:param ChangeDeploymentCompartmentDetails change_deployment_compartment_details: (required)
34+
Details of the target compartment.
35+
36+
:param list[str] wait_for_states:
37+
An array of states to wait on. These should be valid values for :py:attr:`~oci.apigateway.models.WorkRequest.status`
38+
39+
:param dict operation_kwargs:
40+
A dictionary of keyword arguments to pass to :py:func:`~oci.apigateway.DeploymentClient.change_deployment_compartment`
41+
42+
:param dict waiter_kwargs:
43+
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``
44+
as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
45+
"""
46+
operation_result = self.client.change_deployment_compartment(deployment_id, change_deployment_compartment_details, **operation_kwargs)
47+
if not wait_for_states:
48+
return operation_result
49+
50+
lowered_wait_for_states = [w.lower() for w in wait_for_states]
51+
wait_for_resource_id = operation_result.headers['opc-work-request-id']
52+
53+
try:
54+
waiter_result = oci.wait_until(
55+
self.client,
56+
self.client.get_work_request(wait_for_resource_id),
57+
evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_wait_for_states,
58+
**waiter_kwargs
59+
)
60+
result_to_return = waiter_result
61+
62+
return result_to_return
63+
except Exception as e:
64+
raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
65+
66+
def create_deployment_and_wait_for_state(self, create_deployment_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
67+
"""
68+
Calls :py:func:`~oci.apigateway.DeploymentClient.create_deployment` and waits for the :py:class:`~oci.apigateway.models.WorkRequest`
69+
to enter the given state(s).
70+
71+
:param CreateDeploymentDetails create_deployment_details: (required)
72+
Details for the new deployment
73+
74+
:param list[str] wait_for_states:
75+
An array of states to wait on. These should be valid values for :py:attr:`~oci.apigateway.models.WorkRequest.status`
76+
77+
:param dict operation_kwargs:
78+
A dictionary of keyword arguments to pass to :py:func:`~oci.apigateway.DeploymentClient.create_deployment`
79+
80+
:param dict waiter_kwargs:
81+
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``
82+
as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
83+
"""
84+
operation_result = self.client.create_deployment(create_deployment_details, **operation_kwargs)
85+
if not wait_for_states:
86+
return operation_result
87+
88+
lowered_wait_for_states = [w.lower() for w in wait_for_states]
89+
wait_for_resource_id = operation_result.headers['opc-work-request-id']
90+
91+
try:
92+
waiter_result = oci.wait_until(
93+
self.client,
94+
self.client.get_work_request(wait_for_resource_id),
95+
evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_wait_for_states,
96+
**waiter_kwargs
97+
)
98+
result_to_return = waiter_result
99+
100+
return result_to_return
101+
except Exception as e:
102+
raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
103+
104+
def delete_deployment_and_wait_for_state(self, deployment_id, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
105+
"""
106+
Calls :py:func:`~oci.apigateway.DeploymentClient.delete_deployment` and waits for the :py:class:`~oci.apigateway.models.WorkRequest`
107+
to enter the given state(s).
108+
109+
:param str deployment_id: (required)
110+
The ocid of the deployment.
111+
112+
:param list[str] wait_for_states:
113+
An array of states to wait on. These should be valid values for :py:attr:`~oci.apigateway.models.WorkRequest.status`
114+
115+
:param dict operation_kwargs:
116+
A dictionary of keyword arguments to pass to :py:func:`~oci.apigateway.DeploymentClient.delete_deployment`
117+
118+
:param dict waiter_kwargs:
119+
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``
120+
as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
121+
"""
122+
operation_result = None
123+
try:
124+
operation_result = self.client.delete_deployment(deployment_id, **operation_kwargs)
125+
except oci.exceptions.ServiceError as e:
126+
if e.status == 404:
127+
return WAIT_RESOURCE_NOT_FOUND
128+
else:
129+
raise e
130+
131+
if not wait_for_states:
132+
return operation_result
133+
134+
lowered_wait_for_states = [w.lower() for w in wait_for_states]
135+
wait_for_resource_id = operation_result.headers['opc-work-request-id']
136+
137+
try:
138+
waiter_result = oci.wait_until(
139+
self.client,
140+
self.client.get_work_request(wait_for_resource_id),
141+
evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_wait_for_states,
142+
**waiter_kwargs
143+
)
144+
result_to_return = waiter_result
145+
146+
return result_to_return
147+
except Exception as e:
148+
raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)
149+
150+
def update_deployment_and_wait_for_state(self, deployment_id, update_deployment_details, wait_for_states=[], operation_kwargs={}, waiter_kwargs={}):
151+
"""
152+
Calls :py:func:`~oci.apigateway.DeploymentClient.update_deployment` and waits for the :py:class:`~oci.apigateway.models.WorkRequest`
153+
to enter the given state(s).
154+
155+
:param str deployment_id: (required)
156+
The ocid of the deployment.
157+
158+
:param UpdateDeploymentDetails update_deployment_details: (required)
159+
The information to be updated.
160+
161+
:param list[str] wait_for_states:
162+
An array of states to wait on. These should be valid values for :py:attr:`~oci.apigateway.models.WorkRequest.status`
163+
164+
:param dict operation_kwargs:
165+
A dictionary of keyword arguments to pass to :py:func:`~oci.apigateway.DeploymentClient.update_deployment`
166+
167+
:param dict waiter_kwargs:
168+
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``
169+
as dictionary keys to modify how long the waiter function will wait between retries and the maximum amount of time it will wait
170+
"""
171+
operation_result = self.client.update_deployment(deployment_id, update_deployment_details, **operation_kwargs)
172+
if not wait_for_states:
173+
return operation_result
174+
175+
lowered_wait_for_states = [w.lower() for w in wait_for_states]
176+
wait_for_resource_id = operation_result.headers['opc-work-request-id']
177+
178+
try:
179+
waiter_result = oci.wait_until(
180+
self.client,
181+
self.client.get_work_request(wait_for_resource_id),
182+
evaluate_response=lambda r: getattr(r.data, 'status') and getattr(r.data, 'status').lower() in lowered_wait_for_states,
183+
**waiter_kwargs
184+
)
185+
result_to_return = waiter_result
186+
187+
return result_to_return
188+
except Exception as e:
189+
raise oci.exceptions.CompositeOperationError(partial_results=[operation_result], cause=e)

0 commit comments

Comments
 (0)