Client for Purity//FB REST API (1.0 - 1.5), developed by Pure Storage, Inc. Documentations can be found at purity-fb.readthedocs.io.
This Python package is automatically generated by the Swagger Codegen project:
- API version: 1.5
- Package version: 1.5.1
- Build package: io.swagger.codegen.languages.PythonClientCodegen For more information, please visit http://www.purestorage.com
Python 2.7 and 3.4+
There are two ways to use pip to install.
The first is the easiest, i.e., using pypi:
pip install purity_fb
The second is to install from Github:
pip install git+https://github.com/purestorage/purity_fb_python_client.git
(you may need to run pip
with root permission: sudo pip install git+https://github.com/purestorage/purity_fb_python_client.git
)
Then import the package:
import purity_fb
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import purity_fb
Please follow the installation procedure and then run the following:
from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest
# create PurityFb object for a certain array
fb = PurityFb("10.255.8.20")
fb.disable_verify_ssl() # this is required because Purity//FB 2.1 only supports self-signed certificate
try:
fb.login("T-e7e551be-fe5d-4669-baf5-670cd8ea0560")
## manage file systems
fs_obj = FileSystem(name="myfs", provisioned=50000)
# create a file system named myfs
fb.file_systems.create_file_systems(fs_obj)
# list all existing file systems
fb.file_systems.list_file_systems()
# destroy the file system myfs
fb.file_systems.update_file_systems(name="myfs", attributes=FileSystem(destroyed=True))
# eradicate the file system myfs
fb.file_systems.delete_file_systems(name="myfs")
## manage file system snapshots
fb.file_system_snapshots.create_file_system_snapshots(sources=["myfs"], suffix=SnapshotSuffix("mysnap"))
fb.file_system_snapshots.list_file_system_snapshots()
# destroy the file system snapshot myfs.mysnap
fb.file_system_snapshots.update_file_system_snapshots(name="myfs.mysnap", attributes=FileSystemSnapshot(destroyed=True))
# eradicate the file system snapshot myfs.mysnap
fb.file_system_snapshots.delete_file_system_snapshots(name="myfs.mysnap")
fb.logout()
except rest.ApiException as e:
print("Exception: %s\n" % e)
A PurityFb object represents a FlashBlade device.
class purity_fb.PurityFb(host, version=None, api_token=None)
The argument host is required, which is the IP address or host name of the device.
The optional argument version is the REST version number that the client wants to target at. If absent, the latest version is chosen.
The optional argument api_token will be used to log into the array if specified.
Following are generic methods for all versions.
Method | Parameters | Description |
---|---|---|
disable_verify_ssl | none | Disable certificate verification for SSL. This method must be executed before any other calls. |
list_versions | none | List all available REST versions of the array. Public, authentication not required. |
login | api_token | Login to the REST server with a specified api-token. This method must be executed successfully before making any function calls to any APIs. |
logout | n/a | Logout from the REST server |
Note: Purity//FB 2.2 and later versions do support configuring certificates for REST server. However, when a certificate is not configured, a user is required to call disable_verify_ssl before making any other function calls. Once SSL verification is disabled, there will be warnings like the following:
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.20-py3.6.egg/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
These warnings could be disabled using urllib3.disable_warnings.
Once login succeeds, different endpoints could be accessed through the following read-only properties of PurityFb objects.
First, there are general endpoints that are not specific to versions, including api_version and authentication.
Property | Type | Descripstion |
---|---|---|
api_version | VersionApi | Public APIs for querying supported REST versions. |
authentication | AuthenticationApi | Login/logout APIs. |
Second, there are versioned endpoints that are secured by authentication and could be different from version to version. One can specify the version parameter when creating a PurityFb object to choose APIs for a specific REST version. If version is not specified, by default, the most recent REST version available on the server is chosen.
Every method of each endpoint returns an object representing the body of the response from the server.
If other information such as response status code or response header is needed, the corresponding method
XXX_with_http_info()
can be used.
For example,
fb = purity_fb.PurityFb("10.255.3.20")
fb.disable_verify_ssl()
fb.login("T-1eeb15b4-1288-49b2-b0cc-5a7c9e5d524f")
data = fb.file_systems.create_file_systems(FileSystem(name="myfs"))
Here response_data has type FileSystemResponse. And if call with HTTP information, both the response status and header will be returned as well.
(data, status, header) = fb.file_systems.create_file_systems_with_http_info(FileSystem(name="myfs"))
The property PurityFb.request_timeout allows one to get or update the global request timeout used by default for all API calls. The default request_timeout is 10 seconds for connection, and 30 seconds for read.
Property | Type | Descripstion |
---|---|---|
request_timeout | urllib3.Timeout | Set or get the global request timeout for accessing the device. |
For example, fb.request_timeout = urllib3.Timeout(connect=8.0, read=20.0)
. This updates all API call to have 8 seconds connection
timeout and 20 seconds read timeout by default.
All APIs support the keyword parameter _request_timeout (of type urllib3.Timeout ) to specify request timeout for a specific API call.
For example,
fb.file_systems.create_file_systems(FileSystem(name="myfs"), _request_timeout=urllib3.Timeout(connect=5.0, read=15.0))}}
The property PurityFb.request_retry allows one to get or update the global retry setting used by default for all API calls. The default request_retry is 5 retries per call.
Property | Type | Descripstion |
---|---|---|
request_retry | urllib3.Retry | Set or get the global request timeout for accessing the device. |
For example, fb.request_retry = urllib3.Retry(total=20, connect=15, read=15)
. This updates all API call to have
at most 20 retries in total, among which at most 15 connection retries and at most 15 read retries.
- Admin
- AdminApiToken
- AdminCache
- AdminCacheResponse
- AdminResponse
- Alert
- AlertResponse
- AlertWatcher
- AlertWatcherResponse
- AlertWatcherTest
- AlertWatcherTestResponse
- ArrayHttpPerformance
- ArrayHttpPerformanceResponse
- ArrayPerformance
- ArrayPerformanceResponse
- ArrayResponse
- ArrayS3Performance
- ArrayS3PerformanceResponse
- ArraySpace
- ArraySpaceResponse
- Blade
- BladeResponse
- Bucket
- BucketPatch
- BucketPost
- BucketResponse
- BuiltIn
- Certificate
- CertificateResponse
- ClientPerformance
- ClientPerformanceResponse
- DirectoryService
- DirectoryServiceResponse
- DirectoryServiceRole
- DirectoryServiceRolesResponse
- DirectoryServiceSettings
- DirectoryServiceSettingsResponse
- Dns
- DnsResponse
- ErrorResponse
- FileSystem
- FileSystemPerformance
- FileSystemPerformanceResponse
- FileSystemResponse
- FileSystemSnapshot
- FileSystemSnapshotResponse
- Hardware
- HardwareConnector
- HardwareConnectorResponse
- HardwareResponse
- LinkAggregationGroup
- LinkAggregationGroupResponse
- Linkaggregationgroup
- LoginResponse
- NetworkInterface
- NetworkInterfaceResponse
- NfsRule
- ObjectResponse
- ObjectStoreAccessKey
- ObjectStoreAccessKeyResponse
- ObjectStoreAccount
- ObjectStoreAccountResponse
- ObjectStoreUser
- ObjectStoreUserResponse
- Objectstoreaccesskey
- PaginationInfo
- Policy
- PolicyObjects
- PolicyObjectsResponse
- PolicyPatch
- PolicyReference
- PolicyResponse
- ProtocolRule
- PureArray
- PureError
- PureObject
- Reference
- Resource
- ResourceRule
- SmbRule
- Smtp
- SmtpResponse
- SnapshotSuffix
- Space
- Subnet
- SubnetResponse
- TestResult
- TestResultResponse
- VersionResponse
- Type: API key
- API key parameter name: api-token
- Location: URL query string
- Type: API key
- API key parameter name: x-auth-token
- Location: HTTP header