Debian Codegraph @

octavia_tempest_plugin/services/load_balancer/v2/l7policy_client.py

raw symbols SCIP
1 # Copyright 2018 GoDaddy
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 from tempest import config
16
17 from octavia_tempest_plugin.common.decorators import skip_if_not_implemented
18 from octavia_tempest_plugin.services.load_balancer.v2 import base_client
19
20 CONF = config.CONF
21 Unset = base_client.Unset
22
23
24 class L7PolicyClient(base_client.BaseLBaaSClient):
25
26 root_tag = 'l7policy'
27 list_root_tag = 'l7policies'
28 resource_name = 'l7policy'
29
30 @skip_if_not_implemented
31 def create_l7policy(self, listener_id, action, name=Unset,
32 description=Unset, tags=Unset, admin_state_up=Unset,
33 position=Unset, redirect_pool_id=Unset,
34 redirect_url=Unset, return_object_only=True):
35 """Create a l7policy.
36
37 :param listener_id: The ID of the listener for the l7policy.
38 :param action: The l7policy action.
39 :param name: Human-readable name of the resource.
40 :param description: A human-readable description for the resource.
41 :param tags: A human-readable tags of the resource.
42 :param admin_state_up: The administrative state of the resource, which
43 is up (true) or down (false).
44 :param position: The position of this policy on the listener.
45 :param redirect_pool_id: Requests matching this policy will be
46 redirected to the pool with this ID.
47 :param redirect_url: Requests matching this policy will be redirected
48 to this URL.
49 :param return_object_only: If True, the response returns the object
50 inside the root tag. False returns the full
51 response from the API.
52 :raises AssertionError: if the expected_code isn't a valid http success
53 response code
54 :raises BadRequest: If a 400 response code is received
55 :raises Conflict: If a 409 response code is received
56 :raises Forbidden: If a 403 response code is received
57 :raises Gone: If a 410 response code is received
58 :raises InvalidContentType: If a 415 response code is received
59 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
60 :raises InvalidHttpSuccessCode: if the read code isn't an expected
61 http success code
62 :raises NotFound: If a 404 response code is received
63 :raises NotImplemented: If a 501 response code is received
64 :raises OverLimit: If a 413 response code is received and over_limit is
65 not in the response body
66 :raises RateLimitExceeded: If a 413 response code is received and
67 over_limit is in the response body
68 :raises ServerFault: If a 500 response code is received
69 :raises Unauthorized: If a 401 response code is received
70 :raises UnexpectedContentType: If the content-type of the response
71 isn't an expect type
72 :raises UnexpectedResponseCode: If a response code above 400 is
73 received and it doesn't fall into any
74 of the handled checks
75 :raises UnprocessableEntity: If a 422 response code is received and
76 couldn't be parsed
77 :returns: A l7policy object.
78 """
79 kwargs = {arg: value for arg, value in locals().items()
80 if arg != 'self' and value is not Unset}
81 return self._create_object(**kwargs)
82
83 @skip_if_not_implemented
84 def show_l7policy(self, l7policy_id, query_params=None,
85 return_object_only=True):
86 """Get l7policy details.
87
88 :param l7policy_id: The l7policy ID to query.
89 :param query_params: The optional query parameters to append to the
90 request. Ex. fields=id&fields=name
91 :param return_object_only: If True, the response returns the object
92 inside the root tag. False returns the full
93 response from the API.
94 :raises AssertionError: if the expected_code isn't a valid http success
95 response code
96 :raises BadRequest: If a 400 response code is received
97 :raises Conflict: If a 409 response code is received
98 :raises Forbidden: If a 403 response code is received
99 :raises Gone: If a 410 response code is received
100 :raises InvalidContentType: If a 415 response code is received
101 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
102 :raises InvalidHttpSuccessCode: if the read code isn't an expected
103 http success code
104 :raises NotFound: If a 404 response code is received
105 :raises NotImplemented: If a 501 response code is received
106 :raises OverLimit: If a 413 response code is received and over_limit is
107 not in the response body
108 :raises RateLimitExceeded: If a 413 response code is received and
109 over_limit is in the response body
110 :raises ServerFault: If a 500 response code is received
111 :raises Unauthorized: If a 401 response code is received
112 :raises UnexpectedContentType: If the content-type of the response
113 isn't an expect type
114 :raises UnexpectedResponseCode: If a response code above 400 is
115 received and it doesn't fall into any
116 of the handled checks
117 :raises UnprocessableEntity: If a 422 response code is received and
118 couldn't be parsed
119 :returns: A l7policy object.
120 """
121 return self._show_object(obj_id=l7policy_id,
122 query_params=query_params,
123 return_object_only=return_object_only)
124
125 @skip_if_not_implemented
126 def list_l7policies(self, query_params=None, return_object_only=True):
127 """Get a list of l7policy objects.
128
129 :param query_params: The optional query parameters to append to the
130 request. Ex. fields=id&fields=name
131 :param return_object_only: If True, the response returns the object
132 inside the root tag. False returns the full
133 response from the API.
134 :raises AssertionError: if the expected_code isn't a valid http success
135 response code
136 :raises BadRequest: If a 400 response code is received
137 :raises Conflict: If a 409 response code is received
138 :raises Forbidden: If a 403 response code is received
139 :raises Gone: If a 410 response code is received
140 :raises InvalidContentType: If a 415 response code is received
141 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
142 :raises InvalidHttpSuccessCode: if the read code isn't an expected
143 http success code
144 :raises NotFound: If a 404 response code is received
145 :raises NotImplemented: If a 501 response code is received
146 :raises OverLimit: If a 413 response code is received and over_limit is
147 not in the response body
148 :raises RateLimitExceeded: If a 413 response code is received and
149 over_limit is in the response body
150 :raises ServerFault: If a 500 response code is received
151 :raises Unauthorized: If a 401 response code is received
152 :raises UnexpectedContentType: If the content-type of the response
153 isn't an expect type
154 :raises UnexpectedResponseCode: If a response code above 400 is
155 received and it doesn't fall into any
156 of the handled checks
157 :raises UnprocessableEntity: If a 422 response code is received and
158 couldn't be parsed
159 :returns: A list of l7policy objects.
160 """
161 return self._list_objects(query_params=query_params,
162 return_object_only=return_object_only)
163
164 @skip_if_not_implemented
165 def update_l7policy(self, l7policy_id, action=Unset, name=Unset,
166 description=Unset, tags=Unset, admin_state_up=Unset,
167 position=Unset, redirect_pool_id=Unset,
168 redirect_url=Unset, return_object_only=True):
169 """Update a l7policy.
170
171 :param l7policy_id: The l7policy ID to update.
172 :param action: The l7policy action.
173 :param name: Human-readable name of the resource.
174 :param description: A human-readable description for the resource.
175 :param tags: A human-readable tags of the resource.
176 :param admin_state_up: The administrative state of the resource, which
177 is up (true) or down (false).
178 :param position: The position of this policy on the listener.
179 :param redirect_pool_id: Requests matching this policy will be
180 redirected to the pool with this ID.
181 :param redirect_url: Requests matching this policy will be redirected
182 to this URL.
183 :param return_object_only: If True, the response returns the object
184 inside the root tag. False returns the full
185 response from the API.
186 :raises AssertionError: if the expected_code isn't a valid http success
187 response code
188 :raises BadRequest: If a 400 response code is received
189 :raises Conflict: If a 409 response code is received
190 :raises Forbidden: If a 403 response code is received
191 :raises Gone: If a 410 response code is received
192 :raises InvalidContentType: If a 415 response code is received
193 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
194 :raises InvalidHttpSuccessCode: if the read code isn't an expected
195 http success code
196 :raises NotFound: If a 404 response code is received
197 :raises NotImplemented: If a 501 response code is received
198 :raises OverLimit: If a 413 response code is received and over_limit is
199 not in the response body
200 :raises RateLimitExceeded: If a 413 response code is received and
201 over_limit is in the response body
202 :raises ServerFault: If a 500 response code is received
203 :raises Unauthorized: If a 401 response code is received
204 :raises UnexpectedContentType: If the content-type of the response
205 isn't an expect type
206 :raises UnexpectedResponseCode: If a response code above 400 is
207 received and it doesn't fall into any
208 of the handled checks
209 :raises UnprocessableEntity: If a 422 response code is received and
210 couldn't be parsed
211 :returns: A l7policy object.
212 """
213 kwargs = {arg: value for arg, value in locals().items()
214 if arg != 'self' and value is not Unset}
215 kwargs['obj_id'] = kwargs.pop('l7policy_id')
216 return self._update_object(**kwargs)
217
218 @skip_if_not_implemented
219 def delete_l7policy(self, l7policy_id, ignore_errors=False):
220 """Delete a l7policy.
221
222 :param l7policy_id: The l7policy ID to delete.
223 :param ignore_errors: True if errors should be ignored.
224 :raises AssertionError: if the expected_code isn't a valid http success
225 response code
226 :raises BadRequest: If a 400 response code is received
227 :raises Conflict: If a 409 response code is received
228 :raises Forbidden: If a 403 response code is received
229 :raises Gone: If a 410 response code is received
230 :raises InvalidContentType: If a 415 response code is received
231 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
232 :raises InvalidHttpSuccessCode: if the read code isn't an expected
233 http success code
234 :raises NotFound: If a 404 response code is received
235 :raises NotImplemented: If a 501 response code is received
236 :raises OverLimit: If a 413 response code is received and over_limit is
237 not in the response body
238 :raises RateLimitExceeded: If a 413 response code is received and
239 over_limit is in the response body
240 :raises ServerFault: If a 500 response code is received
241 :raises Unauthorized: If a 401 response code is received
242 :raises UnexpectedContentType: If the content-type of the response
243 isn't an expect type
244 :raises UnexpectedResponseCode: If a response code above 400 is
245 received and it doesn't fall into any
246 of the handled checks
247 :raises UnprocessableEntity: If a 422 response code is received and
248 couldn't be parsed
249 :returns: None if ignore_errors is True, the response status code
250 if not.
251 """
252 return self._delete_obj(obj_id=l7policy_id,
253 ignore_errors=ignore_errors)