Skip to content

Commit

Permalink
Merge pull request #73 from oracle/release_2018-09-27
Browse files Browse the repository at this point in the history
Releasing version 2.0.4
  • Loading branch information
Art Hall III authored Sep 27, 2018
2 parents f641ae5 + 8cb7718 commit 3128755
Show file tree
Hide file tree
Showing 65 changed files with 6,710 additions and 76 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <http://keepachangelog.com/>`_.

====================
2.0.3 -2018-09-06
2.0.4 - 2018-09-27
====================

Added
-----
* Support for paravirtualized launch mode when importing images in the Compute service
* Support for Key Management service
* Support for encrypting the contents of an Object Storage bucket using a Key Management service key
* Support for specifying a Key Management service key when launching a compute instance in the Compute service
* Support for specifying a Key Management service key when backing up or restoring a block storage volume in the Block Volume service

Fixed
-----
* ObjectStorageClient requires int value for content_length keyword agruement to put_object and upload_part, but the SDK was not converting the type for the Requests library.

====================
2.0.3 - 2018-09-06
====================

Added
-----
* Added support for updating metadata fields on an instance in the Compute service

Fixed
-------
-----
* Fixed example wait_for_resource_in_state.py to use existing response objects. The updated example can be found on `GitHub <https://github.com/oracle/oci-python-sdk/blob/master/examples/wait_for_resource_in_state.py>`__.

====================
Expand Down
4 changes: 4 additions & 0 deletions docs/api/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Core Services
oci.core.models.BootVolume
oci.core.models.BootVolumeAttachment
oci.core.models.BootVolumeBackup
oci.core.models.BootVolumeKmsKey
oci.core.models.BootVolumeSourceDetails
oci.core.models.BootVolumeSourceFromBootVolumeBackupDetails
oci.core.models.BootVolumeSourceFromBootVolumeDetails
Expand Down Expand Up @@ -131,6 +132,7 @@ Core Services
oci.core.models.UdpOptions
oci.core.models.UpdateBootVolumeBackupDetails
oci.core.models.UpdateBootVolumeDetails
oci.core.models.UpdateBootVolumeKmsKeyDetails
oci.core.models.UpdateConsoleHistoryDetails
oci.core.models.UpdateCpeDetails
oci.core.models.UpdateCrossConnectDetails
Expand All @@ -157,6 +159,7 @@ Core Services
oci.core.models.UpdateVolumeDetails
oci.core.models.UpdateVolumeGroupBackupDetails
oci.core.models.UpdateVolumeGroupDetails
oci.core.models.UpdateVolumeKmsKeyDetails
oci.core.models.Vcn
oci.core.models.VirtualCircuit
oci.core.models.VirtualCircuitBandwidthShape
Expand All @@ -175,6 +178,7 @@ Core Services
oci.core.models.VolumeGroupSourceFromVolumeGroupBackupDetails
oci.core.models.VolumeGroupSourceFromVolumeGroupDetails
oci.core.models.VolumeGroupSourceFromVolumesDetails
oci.core.models.VolumeKmsKey
oci.core.models.VolumeSourceDetails
oci.core.models.VolumeSourceFromVolumeBackupDetails
oci.core.models.VolumeSourceFromVolumeDetails
11 changes: 11 additions & 0 deletions docs/api/core/models/oci.core.models.BootVolumeKmsKey.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BootVolumeKmsKey
================

.. currentmodule:: oci.core.models

.. autoclass:: BootVolumeKmsKey
:show-inheritance:
:special-members: __init__
:members:
:undoc-members:
:inherited-members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
UpdateBootVolumeKmsKeyDetails
=============================

.. currentmodule:: oci.core.models

.. autoclass:: UpdateBootVolumeKmsKeyDetails
:show-inheritance:
:special-members: __init__
:members:
:undoc-members:
:inherited-members:
11 changes: 11 additions & 0 deletions docs/api/core/models/oci.core.models.UpdateVolumeKmsKeyDetails.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
UpdateVolumeKmsKeyDetails
=========================

.. currentmodule:: oci.core.models

.. autoclass:: UpdateVolumeKmsKeyDetails
:show-inheritance:
:special-members: __init__
:members:
:undoc-members:
:inherited-members:
11 changes: 11 additions & 0 deletions docs/api/core/models/oci.core.models.VolumeKmsKey.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
VolumeKmsKey
============

.. currentmodule:: oci.core.models

.. autoclass:: VolumeKmsKey
:show-inheritance:
:special-members: __init__
:members:
:undoc-members:
:inherited-members:
2 changes: 1 addition & 1 deletion docs/upload-manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
Uploading Large Objects
~~~~~~~~~~~~~~~~~~~~~~~~

The Object Storage service supports multipart uploads to make large object uploads easier by splitting the large object into parts. The Python SDK supports raw multipart upload operations for advanced use cases, as well as a higher-level upload class that uses the multipart upload APIs. `Managing Multipart Uploads <https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/managingmultipartuploads.htm>`_ provides links to the APIs used for raw multipart upload operations. Higher-level uploads can be performed using the :py:class:`~oci.object_storage.UploadManager`. The :py:class:`~oci.object_storage.UploadManager` will: split a large object into parts for you, upload the parts in parallel, and then recombine and commit the parts as a single object in Object Storage.
The Object Storage service supports multipart uploads to make large object uploads easier by splitting the large object into parts. The Python SDK supports raw multipart upload operations for advanced use cases, as well as a higher-level upload class that uses the multipart upload APIs. `Using Multipart Uploads <https://docs.cloud.oracle.com/iaas/Content/Object/Tasks/usingmultipartuploads.htm>`_ provides links to the APIs used for raw multipart upload operations. Higher-level uploads can be performed using the :py:class:`~oci.object_storage.UploadManager`. The :py:class:`~oci.object_storage.UploadManager` will: split a large object into parts for you, upload the parts in parallel, and then recombine and commit the parts as a single object in Object Storage.

The `UploadObject <https://github.com/oracle/oci-python-sdk/blob/master/examples/multipart_object_upload.py>`_ example shows how :py:class:`~oci.object_storage.UploadManager` can be used to upload files to object storage.
55 changes: 34 additions & 21 deletions docs/waiters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@
}
</script>

Composite Operations and Waiters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To wait until an attribute of a resource reaches a certain state, you can use composite operations or waiters.

Composite Operations
---------------------
You can use the ``CompositeOperation`` classes in the SDK (e.g. :py:class:`~oci.core.ComputeClientCompositeOperations`)
to perform an action on a resource and wait for it to enter a particular state (or states). The ``CompositeOperation`` classes provide
convenience methods so that you do not have to invoke an operation and then separately invoke a waiter.

An example of using ``CompositeOperation`` classes can be found on `GitHub <https://github.com/oracle/oci-python-sdk/blob/master/examples/composite_operations_example.py>`__.

Waiters
~~~~~~~
Sometimes you may need to wait until an attribute of a resource, such as an instance or a VCN, reaches a certain state. An example of this would be launching an instance and then waiting for the instance to become available, or waiting until a subnet in a VCN has been terminated. This waiting can be accomplished by using the :py:func:`~oci.wait_until` function. As an example:
-------
You can also use the :py:func:`~oci.wait_until` function to wait for a resource to enter a particular state. As an example:

.. code-block:: python
Expand All @@ -34,33 +47,33 @@ Sometimes you may need to wait until an attribute of a resource, such as an inst
# - The fourth parameter is the desired value. An equality (==) comparison is done
get_instance_response = oci.wait_until(client, client.get_instance(instance_ocid), 'lifecycle_state', 'RUNNING')
Instead of waiting for a single attribute to equal a given value, you can also provide a function reference (either a lambda or a reference to an already defined function) that
can be used to evaluate the response received from the service call. This function should return a truthy value if the waiter should stop waiting, and a falsey value if the waiter
should continue waiting.
Passing a Function Reference
``````````````````````````````

For example, to wait until a volume backup reaches either the "AVAILABLE" or "FAULTY" state :
Instead of waiting for a single attribute to reach a given value, you can use a function reference, such as a Lambda expression or a reference to a defined function, to evaluate the response received from the service call. If this function returns a truthy value, the waiter stops waiting.

.. code-block:: python
For example, to wait until a volume backup reaches either the AVAILABLE or FAULTY state :

oci.wait_until(client, client.get_volume_backup(vol_backup_id), evaluate_response=lambda r: r.data.lifecycle_state in ['AVAILABLE', 'FAULTY'])
* Using a Lambda expression:

Instead of using a lambda, an already defined function can be used:
.. code-block:: python
.. code-block:: python
oci.wait_until(client, client.get_volume_backup(vol_backup_id), evaluate_response=lambda r: r.data.lifecycle_state in ['AVAILABLE', 'FAULTY'])
def should_stop_waiting_volume_backup(response):
return response.data.lifecycle_state in ['AVAILABLE', 'FAULTY']
* Using a defined function:

oci.wait_until(client, client.get_volume_backup(vol_backup_id), evaluate_response=should_stop_waiting_volume_backup)
.. code-block:: python
In addition to the base parameters shown above, the function can accept optional attributes to control the maximum amount of time it will wait for and the time between calls to the service. For more information on the optional parameters, see the documentation on the :py:func:`~oci.wait_until` function.
def should_stop_waiting_volume_backup(response):
return response.data.lifecycle_state in ['AVAILABLE', 'FAULTY']
For a more comprehensive sample, please see our `examples <https://github.com/oracle/oci-python-sdk/blob/master/examples/wait_for_resource_in_state.py>`_ on GitHub.
oci.wait_until(client, client.get_volume_backup(vol_backup_id), evaluate_response=should_stop_waiting_volume_backup)
Composite Operations
---------------------
In addition to using waiters, you can use the ``CompositeOperation`` classes in the SDK (e.g. :py:class:`~oci.core.ComputeClientCompositeOperations`)
to perform an action on a resource and wait for it to enter a particular state (or states). The ``CompositeOperation`` classes provide
convenience methods so that you yourself do not have to invoke an operation and then separately invoke a waiter.
Be aware that if the inner function raises an exception, ``oci.wait_until()`` will not be called. In the preceding example, if ``client.get_volume_backup(volume_backup_id)`` raises an exception, ``oci.wait_until()`` will not be called. This happens even if the inner function raises a Not Found exception and ``succeed_on_not_found=True`` is passed to ``oci.wait_until()``.

Optional Attributes
``````````````````````

An example of using ``CompositeOperation`` classes can be found on `GitHub <https://github.com/oracle/oci-python-sdk/blob/master/examples/composite_operations_example.py>`__.
In addition to these base parameters, ``wait_until()`` can accept optional attributes to control the maximum amount of time it will wait and the time between calls to the service. For more information on the optional parameters, see the documentation on the :py:func:`~oci.wait_until` function.

For a more comprehensive sample, please see our `examples <https://github.com/oracle/oci-python-sdk/blob/master/examples/wait_for_resource_in_state.py>`_ on GitHub.
2 changes: 1 addition & 1 deletion examples/container_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def delete_vcn(vn_client, vcn_resources):

# VCNs have default security lists, route tables which cannot be deleted.
# Get the details of the VCN to get the default security list and default route table ids so
# they can be skipped when getting the security lists ans route tables
# they can be skipped when getting the security lists and route tables
response = vn_client.get_vcn(vcn_resources['id'])
default_security_list_id = response.data.default_security_list_id
default_route_table_id = response.data.default_route_table_id
Expand Down
4 changes: 2 additions & 2 deletions src/oci/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.

from . import audit, container_engine, core, database, dns, email, file_storage, identity, load_balancer, object_storage, resource_search
from . import audit, container_engine, core, database, dns, email, file_storage, identity, key_management, load_balancer, object_storage, resource_search
from . import auth, config, constants, decorators, exceptions, regions, pagination, retry
from .base_client import BaseClient
from .request import Request
Expand All @@ -13,5 +13,5 @@

__all__ = [
"BaseClient", "Error", "Request", "Response", "Signer", "config", "constants", "decorators", "exceptions", "regions", "wait_until", "pagination", "auth", "retry",
"audit", "container_engine", "core", "database", "dns", "email", "file_storage", "identity", "load_balancer", "object_storage", "resource_search"
"audit", "container_engine", "core", "database", "dns", "email", "file_storage", "identity", "key_management", "load_balancer", "object_storage", "resource_search"
]
12 changes: 10 additions & 2 deletions src/oci/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(self, service, config, signer, type_mapping, **kwargs):

self._endpoint = None
self._base_path = kwargs.get('base_path')
self.service_endpoint_template = kwargs.get('service_endpoint_template')

if self.regional_client:
if kwargs.get('service_endpoint'):
Expand All @@ -101,11 +102,12 @@ def __init__(self, service, config, signer, type_mapping, **kwargs):

self.endpoint = regions.endpoint_for(
service,
service_endpoint_template=self.service_endpoint_template,
region=region_to_use,
endpoint=config.get('endpoint'))
else:
if not kwargs.get('service_endpoint'):
raise ValueError('An endpoint must be provided for a non-regional service client')
raise exceptions.MissingEndpointForNonRegionalServiceClientError('An endpoint must be provided for a non-regional service client')
self.endpoint = kwargs.get('service_endpoint')

self.service = service
Expand Down Expand Up @@ -141,7 +143,7 @@ def endpoint(self, endpoint):

def set_region(self, region):
if self.regional_client:
self.endpoint = regions.endpoint_for(self.service, region=region)
self.endpoint = regions.endpoint_for(self.service, service_endpoint_template=self.service_endpoint_template, region=region)
else:
raise TypeError('Setting the region is not allowed for non-regional service clients. You must instead set the endpoint')

Expand Down Expand Up @@ -173,6 +175,12 @@ def call_api(self, resource_path, method,

header_params = header_params or {}

# ObjectStorage PutObject and UploadPart require Content-Length as
# int, but requests requires it as a string. All the headers
# have been prepared for serialization at this point
if header_params.get('Content-Length', missing) is not missing:
header_params['Content-Length'] = str(header_params['Content-Length'])

header_params[constants.HEADER_CLIENT_INFO] = USER_INFO
header_params[constants.HEADER_USER_AGENT] = self.user_agent

Expand Down
Loading

0 comments on commit 3128755

Please sign in to comment.