Skip to content

Commit 274dfd3

Browse files
authored
Merge pull request #21 from cc-pure/master
Version 1.19.0
2 parents 0f16511 + 3023163 commit 274dfd3

File tree

5 files changed

+231
-8
lines changed

5 files changed

+231
-8
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ This library requires the use of python 2.6 or later and the third-party
1111
library "requests".
1212

1313
Additionally, this library can only be used communicate with FlashArrays that
14-
support one or more REST API versions between 1.0 and 1.18; currently, this
14+
support one or more REST API versions between 1.0 and 1.19; currently, this
1515
includes any FlashArray running Purity 3.4.0 or later.
1616

1717

1818
Capabilities
1919
============
20-
This library supports all functionality offered by FlashArray REST API versions from 1.0 up to 1.18.
20+
This library supports all functionality offered by FlashArray REST API versions from 1.0 up to 1.19.
2121

2222
Note that different versions of the REST API offer different functionality, and
2323
some operations may be unusable except on certain versions of the REST API. For

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Version Date Notes
2020
1.16.0 10/26/2018 Add support for REST 1.15 and 1.16
2121
1.17.0 08/23/2019 Add support for REST 1.17
2222
1.18.0 11/05/2019 Add support for REST 1.18
23+
1.19.0 06/26/2020 Add support for REST 1.19
2324
======= ========== =====

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
# built documents.
5353
#
5454
# The short X.Y version.
55-
version = '1.18'
55+
version = '1.19'
5656
# The full version, including alpha/beta/rc tags.
57-
release = '1.18.0'
57+
release = '1.19.0'
5858

5959
# The language for content autogenerated by Sphinx. Refer to documentation
6060
# for a list of supported languages.

purestorage/purestorage.py

Lines changed: 224 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from distutils.version import LooseVersion
1414

1515
# The current version of this library.
16-
VERSION = "1.18.0"
16+
VERSION = "1.19.0"
1717

1818

1919
class FlashArray(object):
@@ -89,6 +89,7 @@ class FlashArray(object):
8989
"""
9090

9191
supported_rest_versions = [
92+
"1.19",
9293
"1.18",
9394
"1.17",
9495
"1.16",
@@ -166,7 +167,10 @@ def _request(self, method, path, data=None, reestablish_session=True):
166167
except requests.exceptions.RequestException as err:
167168
# error outside scope of HTTP status codes
168169
# e.g. unable to resolve domain name
169-
raise PureError(err.message)
170+
try:
171+
raise PureError(err.message)
172+
except:
173+
raise PureError(err)
170174

171175
if response.status_code == 200:
172176
if "application/json" in response.headers.get("Content-Type", ""):
@@ -491,6 +495,62 @@ def create_conglomerate_volume(self, volume):
491495
"""
492496
return self._request("POST", "volume/{0}".format(volume), {"protocol_endpoint": True})
493497

498+
def add_tag_to_volume(self, volume, key, value, **kwargs):
499+
"""Add tag to volume and return a dictionary describing it.
500+
501+
:param volume: Name of the volume to add tags to.
502+
:type volume: str
503+
:param key: The Key to a key-value pair of the tag to add to a volume
504+
:type volume: str
505+
:param key: The Value to a key-value pair of the tag to add to a volume
506+
:type volume: str
507+
:param \*\*kwargs: See the REST API Guide on your array for the
508+
documentation on the request:
509+
**POST volume/:volume/tags**
510+
511+
:returns: A dictionary describing the tags added to the volume.
512+
:rtype: ResponseDict
513+
514+
.. note::
515+
516+
Add key/value pairs to a volume.
517+
518+
.. note::
519+
520+
Requires use of REST API 1.19 or later.
521+
522+
"""
523+
data = {"key": key, "value": value}
524+
data.update(kwargs)
525+
return self._request("POST", "volume/{0}/tags".format(volume), data)
526+
527+
def remove_tag_from_volume(self, volume, key, **kwargs):
528+
"""Remove a tag from a volume and return a dictionary describing it.
529+
530+
:param volume: Name of the volume.
531+
:type volume: str
532+
:param key: Name of the key to be deleted
533+
:type volume: str
534+
:param \*\*kwargs: See the REST API Guide on your array for the
535+
documentation on the request:
536+
**DELETE volume/:volume/tags**
537+
538+
:returns: A dictionary describing the tags added to the volume.
539+
:rtype: ResponseDict
540+
541+
.. note::
542+
543+
Remove a key from the volume.
544+
545+
.. note::
546+
547+
Requires use of REST API 1.19 or later.
548+
549+
"""
550+
data = {}
551+
data.update(kwargs)
552+
return self._request("DELETE", "volume/{0}/tags/{1}".format(volume, key), data)
553+
494554
def copy_volume(self, source, dest, **kwargs):
495555
"""Clone a volume and return a dictionary describing the new volume.
496556
@@ -3329,6 +3389,168 @@ def recover_pod(self, pod):
33293389
"""
33303390
return self.set_pod(pod, action="recover")
33313391

3392+
#
3393+
# nearsync methods
3394+
#
3395+
3396+
def create_pod_replica_link(self, local_pod_name, remote_pod_name, **kwargs):
3397+
"""Create replica-link.
3398+
3399+
:param local_pod_name: local pod name.
3400+
:type local_pod_name: str
3401+
:param remote_pod_name: remote pod name.
3402+
:type remote_pod_name: str
3403+
:param \*\*kwargs: See the REST API Guide on your array for the
3404+
documentation on the request:
3405+
**POST pod/replica-link**
3406+
3407+
:returns: a dictionary describing the new replica-link
3408+
:rtype: ResponseDict
3409+
3410+
.. note::
3411+
3412+
Requires use of REST API 1.19 or later.
3413+
3414+
"""
3415+
data = {"local_pod_name": local_pod_name,
3416+
"remote_pod_name": remote_pod_name}
3417+
data.update(kwargs)
3418+
return self._request("POST", "pod/replica-link", data)
3419+
3420+
def delete_pod_replica_link(self, local_pod_name, remote_pod_name):
3421+
"""Delete replica-link.
3422+
3423+
:param local_pod_name: local pod name.
3424+
:type local_pod_name: str
3425+
:param remote_pod_name: remote pod name.
3426+
:type remote_pod_name: str
3427+
3428+
:returns: a dictionary describing the deleted replica-link, contains two pod names of the replica-link
3429+
:rtype: ResponseDict
3430+
3431+
.. note::
3432+
3433+
Requires use of REST API 1.19 or later.
3434+
3435+
"""
3436+
data = {"local_pod_name": local_pod_name,
3437+
"remote_pod_name": remote_pod_name}
3438+
3439+
return self._request("DELETE", "pod/replica-link", data)
3440+
3441+
def list_pod_replica_links(self, **kwargs):
3442+
"""List replica-link.
3443+
3444+
:param \*\*kwargs: See the REST API Guide on your array for the
3445+
documentation on the request:
3446+
**GET pod/replica-link**
3447+
:returns: a dictionary describing the replica-link
3448+
:rtype: ResponseDict
3449+
3450+
.. note::
3451+
3452+
Requires use of REST API 1.19 or later.
3453+
3454+
"""
3455+
data = {}
3456+
if "local_pod_names" in kwargs and kwargs["local_pod_names"]:
3457+
local_pod_names = kwargs.get("local_pod_names")
3458+
builder = ""
3459+
for local_pod_name in local_pod_names:
3460+
builder = builder + local_pod_name + ","
3461+
builder = builder[:-1]
3462+
data = {"local_pod_names": builder}
3463+
data.update(kwargs)
3464+
return self._request("GET", "pod/replica-link", data)
3465+
3466+
def _pause_resume_pod_replica_link(self, **kwargs):
3467+
data = {k: kwargs.get(k) for k in ("local_pod_name", "remote_pod_name", "remote_name", "paused") if kwargs.get(k)}
3468+
data.update(kwargs)
3469+
return self._request("PUT", "pod/replica-link", data)
3470+
3471+
def pause_pod_replica_link(self, local_pod_name, remote_pod_name, **kwargs):
3472+
"""Create replica-link.
3473+
3474+
:param local_pod_name: local pod name.
3475+
:type local_pod_name: str
3476+
:param remote_pod_name: remote pod name.
3477+
:type remote_pod_name: str
3478+
:param \*\*kwargs: See the REST API Guide on your array for the
3479+
documentation on the request:
3480+
**PUT pod/replica-link**
3481+
:returns: a dictionary describing the replica-link
3482+
:rtype: ResponseDict
3483+
3484+
.. note::
3485+
3486+
Requires use of REST API 1.19 or later.
3487+
3488+
"""
3489+
return self._pause_resume_pod_replica_link(
3490+
local_pod_name=local_pod_name, remote_pod_name=remote_pod_name, paused=True, **kwargs)
3491+
3492+
def resume_pod_replica_link(self, local_pod_name, remote_pod_name, **kwargs):
3493+
"""Resume replica-link.
3494+
3495+
:param local_pod_name: local pod name.
3496+
:type local_pod_name: str
3497+
:param remote_pod_name: remote pod name.
3498+
:type remote_pod_name: str
3499+
:param \*\*kwargs: See the REST API Guide on your array for the
3500+
documentation on the request:
3501+
**PUT pod/replica-link**
3502+
:returns: a dictionary describing the replica-link
3503+
:rtype: ResponseDict
3504+
3505+
.. note::
3506+
3507+
Requires use of REST API 1.19 or later.
3508+
3509+
"""
3510+
return self._pause_resume_pod_replica_link(
3511+
local_pod_name=local_pod_name, remote_pod_name=remote_pod_name, paused=False, **kwargs)
3512+
3513+
def _promote_demote_pod(self, pod, **kwargs):
3514+
return self._request("PUT", "pod/{0}".format(pod), kwargs)
3515+
3516+
def promote_pod(self, pod, **kwargs):
3517+
"""Promote pod
3518+
3519+
:param pod: Name of pod to be promoted.
3520+
:type pod: str
3521+
3522+
:param \*\*kwargs: See the REST API Guide on your array for the
3523+
documentation on the request:
3524+
**PUT pod**
3525+
:returns: a dictionary describing a pod
3526+
:rtype: ResponseDict
3527+
3528+
.. note::
3529+
3530+
Requires use of REST API 1.19 or later.
3531+
3532+
"""
3533+
return self._promote_demote_pod(pod, requested_promotion_state="promoted", **kwargs)
3534+
3535+
def demote_pod(self, pod, **kwargs):
3536+
"""Demote pod
3537+
3538+
:param pod: Name of pod to be demoted.
3539+
:type pod: str
3540+
3541+
:param \*\*kwargs: See the REST API Guide on your array for the
3542+
documentation on the request:
3543+
**PUT pod**
3544+
:returns: a dictionary describing a pod
3545+
:rtype: ResponseDict
3546+
3547+
.. note::
3548+
3549+
Requires use of REST API 1.19 or later.
3550+
3551+
"""
3552+
return self._promote_demote_pod(pod, requested_promotion_state="demoted", **kwargs)
3553+
33323554
#
33333555
# SSL Certificate related methods.
33343556
# Note: These methods are not supported before REST API 1.3.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
setup(
88
name="purestorage",
9-
version="1.18.0",
9+
version="1.19.0",
1010
description="Pure Storage FlashArray REST Client",
1111
keywords=["pure", "storage", "flasharray", "rest", "client"],
1212
url="https://github.com/purestorage/rest-client",
13-
download_url="https://github.com/purestorage/rest-client/archive/1.18.0.tar.gz",
13+
download_url="https://github.com/purestorage/rest-client/archive/1.19.0.tar.gz",
1414
author="Pure Storage",
1515
author_email = "wes@purestorage.com",
1616
license="BSD 2-Clause",

0 commit comments

Comments
 (0)