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 5from __future__ import absolute_import 6 7from oci._vendor import requests # noqa: F401 8from oci._vendor import six 9 10from oci import retry, circuit_breaker # noqa: F401 11from oci.base_client import BaseClient 12from oci.config import get_config_value_or_default, validate_config 13from oci.signer import Signer 14from oci.util import Sentinel, get_signer_from_authentication_type, AUTHENTICATION_TYPE_FIELD_NAME 15from .models import usage_api_type_mapping 16missing = Sentinel("Missing") 17 18 19class UsageapiClient(object): 20 """ 21 Use the Usage API to view your Oracle Cloud usage and costs. The API allows you to request data that meets the specified filter criteria, and to group that data by the dimension of your choosing. The Usage API is used by the Cost Analysis tool in the Console. Also see [Using the Usage API](/Content/Billing/Concepts/costanalysisoverview.htm#cost_analysis_using_the_api) for more information. 22 """ 23 24 def __init__(self, config, **kwargs): 25 """ 26 Creates a new service client 27 28 :param dict config: 29 Configuration keys and values as per `SDK and Tool Configuration <https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm>`__. 30 The :py:meth:`~oci.config.from_file` method can be used to load configuration from a file. Alternatively, a ``dict`` can be passed. You can validate_config 31 the dict using :py:meth:`~oci.config.validate_config` 32 33 :param str service_endpoint: (optional) 34 The endpoint of the service to call using this client. For example ``https://iaas.us-ashburn-1.oraclecloud.com``. If this keyword argument is 35 not provided then it will be derived using the region in the config parameter. You should only provide this keyword argument if you have an explicit 36 need to specify a service endpoint. 37 38 :param timeout: (optional) 39 The connection and read timeouts for the client. The default values are connection timeout 10 seconds and read timeout 60 seconds. This keyword argument can be provided 40 as a single float, in which case the value provided is used for both the read and connection timeouts, or as a tuple of two floats. If 41 a tuple is provided then the first value is used as the connection timeout and the second value as the read timeout. 42 :type timeout: float or tuple(float, float) 43 44 :param signer: (optional) 45 The signer to use when signing requests made by the service client. The default is to use a :py:class:`~oci.signer.Signer` based on the values 46 provided in the config parameter. 47 48 One use case for this parameter is for `Instance Principals authentication <https://docs.cloud.oracle.com/Content/Identity/Tasks/callingservicesfrominstances.htm>`__ 49 by passing an instance of :py:class:`~oci.auth.signers.InstancePrincipalsSecurityTokenSigner` as the value for this keyword argument 50 :type signer: :py:class:`~oci.signer.AbstractBaseSigner` 51 52 :param obj retry_strategy: (optional) 53 A retry strategy to apply to all calls made by this service client (i.e. at the client level). There is no retry strategy applied by default. 54 Retry strategies can also be applied at the operation level by passing a ``retry_strategy`` keyword argument as part of calling the operation. 55 Any value provided at the operation level will override whatever is specified at the client level. 56 57 This should be one of the strategies available in the :py:mod:`~oci.retry` module. A convenience :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` 58 is also available. The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 59 60 :param obj circuit_breaker_strategy: (optional) 61 A circuit breaker strategy to apply to all calls made by this service client (i.e. at the client level). 62 This client uses :py:data:`~oci.circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY` as default if no circuit breaker strategy is provided. 63 The specifics of circuit breaker strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/circuit_breakers.html>`__. 64 65 :param function circuit_breaker_callback: (optional) 66 Callback function to receive any exceptions triggerred by the circuit breaker. 67 """ 68 validate_config(config, signer=kwargs.get('signer')) 69 if 'signer' in kwargs: 70 signer = kwargs['signer'] 71 72 elif AUTHENTICATION_TYPE_FIELD_NAME in config: 73 signer = get_signer_from_authentication_type(config) 74 75 else: 76 signer = Signer( 77 tenancy=config["tenancy"], 78 user=config["user"], 79 fingerprint=config["fingerprint"], 80 private_key_file_location=config.get("key_file"), 81 pass_phrase=get_config_value_or_default(config, "pass_phrase"), 82 private_key_content=config.get("key_content") 83 ) 84 85 base_client_init_kwargs = { 86 'regional_client': True, 87 'service_endpoint': kwargs.get('service_endpoint'), 88 'base_path': '/20200107', 89 'service_endpoint_template': 'https://usageapi.{region}.oci.{secondLevelDomain}', 90 'skip_deserialization': kwargs.get('skip_deserialization', False), 91 'circuit_breaker_strategy': kwargs.get('circuit_breaker_strategy', circuit_breaker.GLOBAL_CIRCUIT_BREAKER_STRATEGY) 92 } 93 if 'timeout' in kwargs: 94 base_client_init_kwargs['timeout'] = kwargs.get('timeout') 95 if base_client_init_kwargs.get('circuit_breaker_strategy') is None: 96 base_client_init_kwargs['circuit_breaker_strategy'] = circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY 97 self.base_client = BaseClient("usageapi", config, signer, usage_api_type_mapping, **base_client_init_kwargs) 98 self.retry_strategy = kwargs.get('retry_strategy') 99 self.circuit_breaker_callback = kwargs.get('circuit_breaker_callback') 100 101 def create_custom_table(self, create_custom_table_details, **kwargs): 102 """ 103 Returns the created custom table. 104 105 106 :param oci.usage_api.models.CreateCustomTableDetails create_custom_table_details: (required) 107 New custom table details. 108 109 :param str opc_request_id: (optional) 110 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 111 particular request, please provide the request ID. 112 113 :param str opc_retry_token: (optional) 114 A token that uniquely identifies a request so it can be retried in case of a timeout or 115 server error, without risk of executing that same action again. Retry tokens expire after 24 116 hours, but can be invalidated before then due to conflicting operations. For example, if a resource 117 has been deleted and purged from the system, then a retry of the original creation request 118 might be rejected. 119 120 :param obj retry_strategy: (optional) 121 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 122 123 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 124 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 125 126 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 127 128 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.CustomTable` 129 :rtype: :class:`~oci.response.Response` 130 131 :example: 132 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/create_custom_table.py.html>`__ to see an example of how to use create_custom_table API. 133 """ 134 resource_path = "/customTables" 135 method = "POST" 136 137 # Don't accept unknown kwargs 138 expected_kwargs = [ 139 "retry_strategy", 140 "opc_request_id", 141 "opc_retry_token" 142 ] 143 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 144 if extra_kwargs: 145 raise ValueError( 146 "create_custom_table got unknown kwargs: {!r}".format(extra_kwargs)) 147 148 header_params = { 149 "accept": "application/json", 150 "content-type": "application/json", 151 "opc-request-id": kwargs.get("opc_request_id", missing), 152 "opc-retry-token": kwargs.get("opc_retry_token", missing) 153 } 154 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 155 156 retry_strategy = self.base_client.get_preferred_retry_strategy( 157 operation_retry_strategy=kwargs.get('retry_strategy'), 158 client_retry_strategy=self.retry_strategy 159 ) 160 161 if retry_strategy: 162 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 163 self.base_client.add_opc_retry_token_if_needed(header_params) 164 self.base_client.add_opc_client_retries_header(header_params) 165 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 166 return retry_strategy.make_retrying_call( 167 self.base_client.call_api, 168 resource_path=resource_path, 169 method=method, 170 header_params=header_params, 171 body=create_custom_table_details, 172 response_type="CustomTable") 173 else: 174 return self.base_client.call_api( 175 resource_path=resource_path, 176 method=method, 177 header_params=header_params, 178 body=create_custom_table_details, 179 response_type="CustomTable") 180 181 def create_query(self, create_query_details, **kwargs): 182 """ 183 Returns the created query. 184 185 186 :param oci.usage_api.models.CreateQueryDetails create_query_details: (required) 187 New query details. Up to ten saved queries. 188 189 :param str opc_request_id: (optional) 190 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 191 particular request, please provide the request ID. 192 193 :param str opc_retry_token: (optional) 194 A token that uniquely identifies a request so it can be retried in case of a timeout or 195 server error, without risk of executing that same action again. Retry tokens expire after 24 196 hours, but can be invalidated before then due to conflicting operations. For example, if a resource 197 has been deleted and purged from the system, then a retry of the original creation request 198 might be rejected. 199 200 :param obj retry_strategy: (optional) 201 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 202 203 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 204 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 205 206 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 207 208 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.Query` 209 :rtype: :class:`~oci.response.Response` 210 211 :example: 212 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/create_query.py.html>`__ to see an example of how to use create_query API. 213 """ 214 resource_path = "/queries" 215 method = "POST" 216 217 # Don't accept unknown kwargs 218 expected_kwargs = [ 219 "retry_strategy", 220 "opc_request_id", 221 "opc_retry_token" 222 ] 223 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 224 if extra_kwargs: 225 raise ValueError( 226 "create_query got unknown kwargs: {!r}".format(extra_kwargs)) 227 228 header_params = { 229 "accept": "application/json", 230 "content-type": "application/json", 231 "opc-request-id": kwargs.get("opc_request_id", missing), 232 "opc-retry-token": kwargs.get("opc_retry_token", missing) 233 } 234 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 235 236 retry_strategy = self.base_client.get_preferred_retry_strategy( 237 operation_retry_strategy=kwargs.get('retry_strategy'), 238 client_retry_strategy=self.retry_strategy 239 ) 240 241 if retry_strategy: 242 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 243 self.base_client.add_opc_retry_token_if_needed(header_params) 244 self.base_client.add_opc_client_retries_header(header_params) 245 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 246 return retry_strategy.make_retrying_call( 247 self.base_client.call_api, 248 resource_path=resource_path, 249 method=method, 250 header_params=header_params, 251 body=create_query_details, 252 response_type="Query") 253 else: 254 return self.base_client.call_api( 255 resource_path=resource_path, 256 method=method, 257 header_params=header_params, 258 body=create_query_details, 259 response_type="Query") 260 261 def delete_custom_table(self, custom_table_id, **kwargs): 262 """ 263 Delete a saved custom table by the OCID. 264 265 266 :param str custom_table_id: (required) 267 The custom table unique OCID. 268 269 :param str opc_request_id: (optional) 270 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 271 particular request, please provide the request ID. 272 273 :param str if_match: (optional) 274 For optimistic concurrency control. In the PUT or DELETE call 275 for a resource, set the `if-match` parameter to the value of the 276 etag from a previous GET or POST response for that resource. 277 The resource will be updated or deleted, only if the etag you 278 provide matches the resource's current etag value. 279 280 :param obj retry_strategy: (optional) 281 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 282 283 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 284 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 285 286 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 287 288 :return: A :class:`~oci.response.Response` object with data of type None 289 :rtype: :class:`~oci.response.Response` 290 291 :example: 292 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/delete_custom_table.py.html>`__ to see an example of how to use delete_custom_table API. 293 """ 294 resource_path = "/customTables/{customTableId}" 295 method = "DELETE" 296 297 # Don't accept unknown kwargs 298 expected_kwargs = [ 299 "retry_strategy", 300 "opc_request_id", 301 "if_match" 302 ] 303 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 304 if extra_kwargs: 305 raise ValueError( 306 "delete_custom_table got unknown kwargs: {!r}".format(extra_kwargs)) 307 308 path_params = { 309 "customTableId": custom_table_id 310 } 311 312 path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} 313 314 for (k, v) in six.iteritems(path_params): 315 if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): 316 raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) 317 318 header_params = { 319 "accept": "application/json", 320 "content-type": "application/json", 321 "opc-request-id": kwargs.get("opc_request_id", missing), 322 "if-match": kwargs.get("if_match", missing) 323 } 324 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 325 326 retry_strategy = self.base_client.get_preferred_retry_strategy( 327 operation_retry_strategy=kwargs.get('retry_strategy'), 328 client_retry_strategy=self.retry_strategy 329 ) 330 331 if retry_strategy: 332 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 333 self.base_client.add_opc_client_retries_header(header_params) 334 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 335 return retry_strategy.make_retrying_call( 336 self.base_client.call_api, 337 resource_path=resource_path, 338 method=method, 339 path_params=path_params, 340 header_params=header_params) 341 else: 342 return self.base_client.call_api( 343 resource_path=resource_path, 344 method=method, 345 path_params=path_params, 346 header_params=header_params) 347 348 def delete_query(self, query_id, **kwargs): 349 """ 350 Delete a saved query by the OCID. 351 352 353 :param str query_id: (required) 354 The query unique OCID. 355 356 :param str opc_request_id: (optional) 357 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 358 particular request, please provide the request ID. 359 360 :param str if_match: (optional) 361 For optimistic concurrency control. In the PUT or DELETE call 362 for a resource, set the `if-match` parameter to the value of the 363 etag from a previous GET or POST response for that resource. 364 The resource will be updated or deleted, only if the etag you 365 provide matches the resource's current etag value. 366 367 :param obj retry_strategy: (optional) 368 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 369 370 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 371 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 372 373 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 374 375 :return: A :class:`~oci.response.Response` object with data of type None 376 :rtype: :class:`~oci.response.Response` 377 378 :example: 379 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/delete_query.py.html>`__ to see an example of how to use delete_query API. 380 """ 381 resource_path = "/queries/{queryId}" 382 method = "DELETE" 383 384 # Don't accept unknown kwargs 385 expected_kwargs = [ 386 "retry_strategy", 387 "opc_request_id", 388 "if_match" 389 ] 390 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 391 if extra_kwargs: 392 raise ValueError( 393 "delete_query got unknown kwargs: {!r}".format(extra_kwargs)) 394 395 path_params = { 396 "queryId": query_id 397 } 398 399 path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} 400 401 for (k, v) in six.iteritems(path_params): 402 if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): 403 raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) 404 405 header_params = { 406 "accept": "application/json", 407 "content-type": "application/json", 408 "opc-request-id": kwargs.get("opc_request_id", missing), 409 "if-match": kwargs.get("if_match", missing) 410 } 411 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 412 413 retry_strategy = self.base_client.get_preferred_retry_strategy( 414 operation_retry_strategy=kwargs.get('retry_strategy'), 415 client_retry_strategy=self.retry_strategy 416 ) 417 418 if retry_strategy: 419 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 420 self.base_client.add_opc_client_retries_header(header_params) 421 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 422 return retry_strategy.make_retrying_call( 423 self.base_client.call_api, 424 resource_path=resource_path, 425 method=method, 426 path_params=path_params, 427 header_params=header_params) 428 else: 429 return self.base_client.call_api( 430 resource_path=resource_path, 431 method=method, 432 path_params=path_params, 433 header_params=header_params) 434 435 def get_custom_table(self, custom_table_id, **kwargs): 436 """ 437 Returns the saved custom table. 438 439 440 :param str custom_table_id: (required) 441 The custom table unique OCID. 442 443 :param str opc_request_id: (optional) 444 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 445 particular request, please provide the request ID. 446 447 :param obj retry_strategy: (optional) 448 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 449 450 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 451 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 452 453 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 454 455 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.CustomTable` 456 :rtype: :class:`~oci.response.Response` 457 458 :example: 459 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/get_custom_table.py.html>`__ to see an example of how to use get_custom_table API. 460 """ 461 resource_path = "/customTables/{customTableId}" 462 method = "GET" 463 464 # Don't accept unknown kwargs 465 expected_kwargs = [ 466 "retry_strategy", 467 "opc_request_id" 468 ] 469 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 470 if extra_kwargs: 471 raise ValueError( 472 "get_custom_table got unknown kwargs: {!r}".format(extra_kwargs)) 473 474 path_params = { 475 "customTableId": custom_table_id 476 } 477 478 path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} 479 480 for (k, v) in six.iteritems(path_params): 481 if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): 482 raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) 483 484 header_params = { 485 "accept": "application/json", 486 "content-type": "application/json", 487 "opc-request-id": kwargs.get("opc_request_id", missing) 488 } 489 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 490 491 retry_strategy = self.base_client.get_preferred_retry_strategy( 492 operation_retry_strategy=kwargs.get('retry_strategy'), 493 client_retry_strategy=self.retry_strategy 494 ) 495 496 if retry_strategy: 497 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 498 self.base_client.add_opc_client_retries_header(header_params) 499 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 500 return retry_strategy.make_retrying_call( 501 self.base_client.call_api, 502 resource_path=resource_path, 503 method=method, 504 path_params=path_params, 505 header_params=header_params, 506 response_type="CustomTable") 507 else: 508 return self.base_client.call_api( 509 resource_path=resource_path, 510 method=method, 511 path_params=path_params, 512 header_params=header_params, 513 response_type="CustomTable") 514 515 def get_query(self, query_id, **kwargs): 516 """ 517 Returns the saved query. 518 519 520 :param str query_id: (required) 521 The query unique OCID. 522 523 :param str opc_request_id: (optional) 524 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 525 particular request, please provide the request ID. 526 527 :param obj retry_strategy: (optional) 528 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 529 530 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 531 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 532 533 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 534 535 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.Query` 536 :rtype: :class:`~oci.response.Response` 537 538 :example: 539 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/get_query.py.html>`__ to see an example of how to use get_query API. 540 """ 541 resource_path = "/queries/{queryId}" 542 method = "GET" 543 544 # Don't accept unknown kwargs 545 expected_kwargs = [ 546 "retry_strategy", 547 "opc_request_id" 548 ] 549 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 550 if extra_kwargs: 551 raise ValueError( 552 "get_query got unknown kwargs: {!r}".format(extra_kwargs)) 553 554 path_params = { 555 "queryId": query_id 556 } 557 558 path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} 559 560 for (k, v) in six.iteritems(path_params): 561 if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): 562 raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) 563 564 header_params = { 565 "accept": "application/json", 566 "content-type": "application/json", 567 "opc-request-id": kwargs.get("opc_request_id", missing) 568 } 569 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 570 571 retry_strategy = self.base_client.get_preferred_retry_strategy( 572 operation_retry_strategy=kwargs.get('retry_strategy'), 573 client_retry_strategy=self.retry_strategy 574 ) 575 576 if retry_strategy: 577 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 578 self.base_client.add_opc_client_retries_header(header_params) 579 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 580 return retry_strategy.make_retrying_call( 581 self.base_client.call_api, 582 resource_path=resource_path, 583 method=method, 584 path_params=path_params, 585 header_params=header_params, 586 response_type="Query") 587 else: 588 return self.base_client.call_api( 589 resource_path=resource_path, 590 method=method, 591 path_params=path_params, 592 header_params=header_params, 593 response_type="Query") 594 595 def list_custom_tables(self, compartment_id, saved_report_id, **kwargs): 596 """ 597 Returns the saved custom table list. 598 599 600 :param str compartment_id: (required) 601 The compartment ID in which to list resources. 602 603 :param str saved_report_id: (required) 604 The saved report ID in which to list resources. 605 606 :param str opc_request_id: (optional) 607 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 608 particular request, please provide the request ID. 609 610 :param int limit: (optional) 611 The maximumimum number of items to return. 612 613 :param str page: (optional) 614 The page token representing the page at which to start retrieving results. 615 This is usually retrieved from a previous list call. 616 617 :param str sort_by: (optional) 618 The field to sort by. If not specified, the default is displayName. 619 620 Allowed values are: "displayName" 621 622 :param str sort_order: (optional) 623 The sort order to use, whether 'asc' or 'desc'. 624 625 Allowed values are: "ASC", "DESC" 626 627 :param obj retry_strategy: (optional) 628 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 629 630 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 631 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 632 633 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 634 635 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.CustomTableCollection` 636 :rtype: :class:`~oci.response.Response` 637 638 :example: 639 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/list_custom_tables.py.html>`__ to see an example of how to use list_custom_tables API. 640 """ 641 resource_path = "/customTables" 642 method = "GET" 643 644 # Don't accept unknown kwargs 645 expected_kwargs = [ 646 "retry_strategy", 647 "opc_request_id", 648 "limit", 649 "page", 650 "sort_by", 651 "sort_order" 652 ] 653 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 654 if extra_kwargs: 655 raise ValueError( 656 "list_custom_tables got unknown kwargs: {!r}".format(extra_kwargs)) 657 658 if 'sort_by' in kwargs: 659 sort_by_allowed_values = ["displayName"] 660 if kwargs['sort_by'] not in sort_by_allowed_values: 661 raise ValueError( 662 "Invalid value for `sort_by`, must be one of {0}".format(sort_by_allowed_values) 663 ) 664 665 if 'sort_order' in kwargs: 666 sort_order_allowed_values = ["ASC", "DESC"] 667 if kwargs['sort_order'] not in sort_order_allowed_values: 668 raise ValueError( 669 "Invalid value for `sort_order`, must be one of {0}".format(sort_order_allowed_values) 670 ) 671 672 query_params = { 673 "limit": kwargs.get("limit", missing), 674 "page": kwargs.get("page", missing), 675 "compartmentId": compartment_id, 676 "savedReportId": saved_report_id, 677 "sortBy": kwargs.get("sort_by", missing), 678 "sortOrder": kwargs.get("sort_order", missing) 679 } 680 query_params = {k: v for (k, v) in six.iteritems(query_params) if v is not missing and v is not None} 681 682 header_params = { 683 "accept": "application/json", 684 "content-type": "application/json", 685 "opc-request-id": kwargs.get("opc_request_id", missing) 686 } 687 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 688 689 retry_strategy = self.base_client.get_preferred_retry_strategy( 690 operation_retry_strategy=kwargs.get('retry_strategy'), 691 client_retry_strategy=self.retry_strategy 692 ) 693 694 if retry_strategy: 695 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 696 self.base_client.add_opc_client_retries_header(header_params) 697 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 698 return retry_strategy.make_retrying_call( 699 self.base_client.call_api, 700 resource_path=resource_path, 701 method=method, 702 query_params=query_params, 703 header_params=header_params, 704 response_type="CustomTableCollection") 705 else: 706 return self.base_client.call_api( 707 resource_path=resource_path, 708 method=method, 709 query_params=query_params, 710 header_params=header_params, 711 response_type="CustomTableCollection") 712 713 def list_queries(self, compartment_id, **kwargs): 714 """ 715 Returns the saved query list. 716 717 718 :param str compartment_id: (required) 719 The compartment ID in which to list resources. 720 721 :param str opc_request_id: (optional) 722 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 723 particular request, please provide the request ID. 724 725 :param int limit: (optional) 726 The maximumimum number of items to return. 727 728 :param str page: (optional) 729 The page token representing the page at which to start retrieving results. 730 This is usually retrieved from a previous list call. 731 732 :param str sort_by: (optional) 733 The field to sort by. If not specified, the default is displayName. 734 735 Allowed values are: "displayName" 736 737 :param str sort_order: (optional) 738 The sort order to use, whether 'asc' or 'desc'. 739 740 Allowed values are: "ASC", "DESC" 741 742 :param obj retry_strategy: (optional) 743 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 744 745 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 746 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 747 748 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 749 750 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.QueryCollection` 751 :rtype: :class:`~oci.response.Response` 752 753 :example: 754 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/list_queries.py.html>`__ to see an example of how to use list_queries API. 755 """ 756 resource_path = "/queries" 757 method = "GET" 758 759 # Don't accept unknown kwargs 760 expected_kwargs = [ 761 "retry_strategy", 762 "opc_request_id", 763 "limit", 764 "page", 765 "sort_by", 766 "sort_order" 767 ] 768 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 769 if extra_kwargs: 770 raise ValueError( 771 "list_queries got unknown kwargs: {!r}".format(extra_kwargs)) 772 773 if 'sort_by' in kwargs: 774 sort_by_allowed_values = ["displayName"] 775 if kwargs['sort_by'] not in sort_by_allowed_values: 776 raise ValueError( 777 "Invalid value for `sort_by`, must be one of {0}".format(sort_by_allowed_values) 778 ) 779 780 if 'sort_order' in kwargs: 781 sort_order_allowed_values = ["ASC", "DESC"] 782 if kwargs['sort_order'] not in sort_order_allowed_values: 783 raise ValueError( 784 "Invalid value for `sort_order`, must be one of {0}".format(sort_order_allowed_values) 785 ) 786 787 query_params = { 788 "limit": kwargs.get("limit", missing), 789 "page": kwargs.get("page", missing), 790 "compartmentId": compartment_id, 791 "sortBy": kwargs.get("sort_by", missing), 792 "sortOrder": kwargs.get("sort_order", missing) 793 } 794 query_params = {k: v for (k, v) in six.iteritems(query_params) if v is not missing and v is not None} 795 796 header_params = { 797 "accept": "application/json", 798 "content-type": "application/json", 799 "opc-request-id": kwargs.get("opc_request_id", missing) 800 } 801 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 802 803 retry_strategy = self.base_client.get_preferred_retry_strategy( 804 operation_retry_strategy=kwargs.get('retry_strategy'), 805 client_retry_strategy=self.retry_strategy 806 ) 807 808 if retry_strategy: 809 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 810 self.base_client.add_opc_client_retries_header(header_params) 811 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 812 return retry_strategy.make_retrying_call( 813 self.base_client.call_api, 814 resource_path=resource_path, 815 method=method, 816 query_params=query_params, 817 header_params=header_params, 818 response_type="QueryCollection") 819 else: 820 return self.base_client.call_api( 821 resource_path=resource_path, 822 method=method, 823 query_params=query_params, 824 header_params=header_params, 825 response_type="QueryCollection") 826 827 def request_summarized_configurations(self, tenant_id, **kwargs): 828 """ 829 Returns the configurations list for the UI drop-down list. 830 831 832 :param str tenant_id: (required) 833 tenant id 834 835 :param str opc_request_id: (optional) 836 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 837 particular request, please provide the request ID. 838 839 :param obj retry_strategy: (optional) 840 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 841 842 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 843 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 844 845 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 846 847 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.ConfigurationAggregation` 848 :rtype: :class:`~oci.response.Response` 849 850 :example: 851 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/request_summarized_configurations.py.html>`__ to see an example of how to use request_summarized_configurations API. 852 """ 853 resource_path = "/configuration" 854 method = "GET" 855 856 # Don't accept unknown kwargs 857 expected_kwargs = [ 858 "retry_strategy", 859 "opc_request_id" 860 ] 861 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 862 if extra_kwargs: 863 raise ValueError( 864 "request_summarized_configurations got unknown kwargs: {!r}".format(extra_kwargs)) 865 866 query_params = { 867 "tenantId": tenant_id 868 } 869 query_params = {k: v for (k, v) in six.iteritems(query_params) if v is not missing and v is not None} 870 871 header_params = { 872 "accept": "application/json", 873 "content-type": "application/json", 874 "opc-request-id": kwargs.get("opc_request_id", missing) 875 } 876 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 877 878 retry_strategy = self.base_client.get_preferred_retry_strategy( 879 operation_retry_strategy=kwargs.get('retry_strategy'), 880 client_retry_strategy=self.retry_strategy 881 ) 882 883 if retry_strategy: 884 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 885 self.base_client.add_opc_client_retries_header(header_params) 886 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 887 return retry_strategy.make_retrying_call( 888 self.base_client.call_api, 889 resource_path=resource_path, 890 method=method, 891 query_params=query_params, 892 header_params=header_params, 893 response_type="ConfigurationAggregation") 894 else: 895 return self.base_client.call_api( 896 resource_path=resource_path, 897 method=method, 898 query_params=query_params, 899 header_params=header_params, 900 response_type="ConfigurationAggregation") 901 902 def request_summarized_usages(self, request_summarized_usages_details, **kwargs): 903 """ 904 Returns usage for the given account. 905 906 907 :param oci.usage_api.models.RequestSummarizedUsagesDetails request_summarized_usages_details: (required) 908 getUsageRequest contains query inforamtion. 909 910 :param str opc_request_id: (optional) 911 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 912 particular request, please provide the request ID. 913 914 :param str page: (optional) 915 The page token representing the page at which to start retrieving results. 916 This is usually retrieved from a previous list call. 917 918 :param int limit: (optional) 919 The maximumimum number of items to return. 920 921 :param obj retry_strategy: (optional) 922 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 923 924 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 925 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 926 927 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 928 929 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.UsageAggregation` 930 :rtype: :class:`~oci.response.Response` 931 932 :example: 933 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/request_summarized_usages.py.html>`__ to see an example of how to use request_summarized_usages API. 934 """ 935 resource_path = "/usage" 936 method = "POST" 937 938 # Don't accept unknown kwargs 939 expected_kwargs = [ 940 "retry_strategy", 941 "opc_request_id", 942 "page", 943 "limit" 944 ] 945 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 946 if extra_kwargs: 947 raise ValueError( 948 "request_summarized_usages got unknown kwargs: {!r}".format(extra_kwargs)) 949 950 query_params = { 951 "page": kwargs.get("page", missing), 952 "limit": kwargs.get("limit", missing) 953 } 954 query_params = {k: v for (k, v) in six.iteritems(query_params) if v is not missing and v is not None} 955 956 header_params = { 957 "accept": "application/json", 958 "content-type": "application/json", 959 "opc-request-id": kwargs.get("opc_request_id", missing) 960 } 961 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 962 963 retry_strategy = self.base_client.get_preferred_retry_strategy( 964 operation_retry_strategy=kwargs.get('retry_strategy'), 965 client_retry_strategy=self.retry_strategy 966 ) 967 968 if retry_strategy: 969 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 970 self.base_client.add_opc_client_retries_header(header_params) 971 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 972 return retry_strategy.make_retrying_call( 973 self.base_client.call_api, 974 resource_path=resource_path, 975 method=method, 976 query_params=query_params, 977 header_params=header_params, 978 body=request_summarized_usages_details, 979 response_type="UsageAggregation") 980 else: 981 return self.base_client.call_api( 982 resource_path=resource_path, 983 method=method, 984 query_params=query_params, 985 header_params=header_params, 986 body=request_summarized_usages_details, 987 response_type="UsageAggregation") 988 989 def update_custom_table(self, update_custom_table_details, custom_table_id, **kwargs): 990 """ 991 Update a saved custom table by table id. 992 993 994 :param oci.usage_api.models.UpdateCustomTableDetails update_custom_table_details: (required) 995 The information to be updated. 996 997 :param str custom_table_id: (required) 998 The custom table unique OCID. 999 1000 :param str opc_request_id: (optional) 1001 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 1002 particular request, please provide the request ID. 1003 1004 :param str if_match: (optional) 1005 For optimistic concurrency control. In the PUT or DELETE call 1006 for a resource, set the `if-match` parameter to the value of the 1007 etag from a previous GET or POST response for that resource. 1008 The resource will be updated or deleted, only if the etag you 1009 provide matches the resource's current etag value. 1010 1011 :param obj retry_strategy: (optional) 1012 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 1013 1014 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 1015 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 1016 1017 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 1018 1019 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.CustomTable` 1020 :rtype: :class:`~oci.response.Response` 1021 1022 :example: 1023 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/update_custom_table.py.html>`__ to see an example of how to use update_custom_table API. 1024 """ 1025 resource_path = "/customTables/{customTableId}" 1026 method = "PUT" 1027 1028 # Don't accept unknown kwargs 1029 expected_kwargs = [ 1030 "retry_strategy", 1031 "opc_request_id", 1032 "if_match" 1033 ] 1034 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 1035 if extra_kwargs: 1036 raise ValueError( 1037 "update_custom_table got unknown kwargs: {!r}".format(extra_kwargs)) 1038 1039 path_params = { 1040 "customTableId": custom_table_id 1041 } 1042 1043 path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} 1044 1045 for (k, v) in six.iteritems(path_params): 1046 if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): 1047 raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) 1048 1049 header_params = { 1050 "accept": "application/json", 1051 "content-type": "application/json", 1052 "opc-request-id": kwargs.get("opc_request_id", missing), 1053 "if-match": kwargs.get("if_match", missing) 1054 } 1055 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 1056 1057 retry_strategy = self.base_client.get_preferred_retry_strategy( 1058 operation_retry_strategy=kwargs.get('retry_strategy'), 1059 client_retry_strategy=self.retry_strategy 1060 ) 1061 1062 if retry_strategy: 1063 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 1064 self.base_client.add_opc_client_retries_header(header_params) 1065 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 1066 return retry_strategy.make_retrying_call( 1067 self.base_client.call_api, 1068 resource_path=resource_path, 1069 method=method, 1070 path_params=path_params, 1071 header_params=header_params, 1072 body=update_custom_table_details, 1073 response_type="CustomTable") 1074 else: 1075 return self.base_client.call_api( 1076 resource_path=resource_path, 1077 method=method, 1078 path_params=path_params, 1079 header_params=header_params, 1080 body=update_custom_table_details, 1081 response_type="CustomTable") 1082 1083 def update_query(self, update_query_details, query_id, **kwargs): 1084 """ 1085 Update a saved query by the OCID. 1086 1087 1088 :param oci.usage_api.models.UpdateQueryDetails update_query_details: (required) 1089 The information to be updated. 1090 1091 :param str query_id: (required) 1092 The query unique OCID. 1093 1094 :param str opc_request_id: (optional) 1095 Unique Oracle-assigned identifier for the request. If you need to contact Oracle about a 1096 particular request, please provide the request ID. 1097 1098 :param str if_match: (optional) 1099 For optimistic concurrency control. In the PUT or DELETE call 1100 for a resource, set the `if-match` parameter to the value of the 1101 etag from a previous GET or POST response for that resource. 1102 The resource will be updated or deleted, only if the etag you 1103 provide matches the resource's current etag value. 1104 1105 :param obj retry_strategy: (optional) 1106 A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. 1107 1108 This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. 1109 The specifics of the default retry strategy are described `here <https://docs.oracle.com/en-us/iaas/tools/python/latest/sdk_behaviors/retries.html>`__. 1110 1111 To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. 1112 1113 :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage_api.models.Query` 1114 :rtype: :class:`~oci.response.Response` 1115 1116 :example: 1117 Click `here <https://docs.cloud.oracle.com/en-us/iaas/tools/python-sdk-examples/2.53.1/usageapi/update_query.py.html>`__ to see an example of how to use update_query API. 1118 """ 1119 resource_path = "/queries/{queryId}" 1120 method = "PUT" 1121 1122 # Don't accept unknown kwargs 1123 expected_kwargs = [ 1124 "retry_strategy", 1125 "opc_request_id", 1126 "if_match" 1127 ] 1128 extra_kwargs = [_key for _key in six.iterkeys(kwargs) if _key not in expected_kwargs] 1129 if extra_kwargs: 1130 raise ValueError( 1131 "update_query got unknown kwargs: {!r}".format(extra_kwargs)) 1132 1133 path_params = { 1134 "queryId": query_id 1135 } 1136 1137 path_params = {k: v for (k, v) in six.iteritems(path_params) if v is not missing} 1138 1139 for (k, v) in six.iteritems(path_params): 1140 if v is None or (isinstance(v, six.string_types) and len(v.strip()) == 0): 1141 raise ValueError('Parameter {} cannot be None, whitespace or empty string'.format(k)) 1142 1143 header_params = { 1144 "accept": "application/json", 1145 "content-type": "application/json", 1146 "opc-request-id": kwargs.get("opc_request_id", missing), 1147 "if-match": kwargs.get("if_match", missing) 1148 } 1149 header_params = {k: v for (k, v) in six.iteritems(header_params) if v is not missing and v is not None} 1150 1151 retry_strategy = self.base_client.get_preferred_retry_strategy( 1152 operation_retry_strategy=kwargs.get('retry_strategy'), 1153 client_retry_strategy=self.retry_strategy 1154 ) 1155 1156 if retry_strategy: 1157 if not isinstance(retry_strategy, retry.NoneRetryStrategy): 1158 self.base_client.add_opc_client_retries_header(header_params) 1159 retry_strategy.add_circuit_breaker_callback(self.circuit_breaker_callback) 1160 return retry_strategy.make_retrying_call( 1161 self.base_client.call_api, 1162 resource_path=resource_path, 1163 method=method, 1164 path_params=path_params, 1165 header_params=header_params, 1166 body=update_query_details, 1167 response_type="Query") 1168 else: 1169 return self.base_client.call_api( 1170 resource_path=resource_path, 1171 method=method, 1172 path_params=path_params, 1173 header_params=header_params, 1174 body=update_query_details, 1175 response_type="Query") 1176