Skip to content

Commit 246b571

Browse files
author
Gregory-Bessonov
authored
Missing examples added (#96)
1 parent 75ed494 commit 246b571

30 files changed

+1050
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# delete a bucket access policy by bucket name
2+
client.delete_buckets_bucket_access_policies(bucket_names=["bkt1"])
3+
# delete a bucket access policy by bucket id
4+
client.delete_buckets_bucket_access_policies(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"])
5+
# delete a bucket access policy by name
6+
client.delete_buckets_bucket_access_policies(names=["bkt1/access-policy"])
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# delete a bucket access policy rule by bucket name
2+
client.delete_buckets_bucket_access_policies_rules(bucket_names=["bkt1"], names=["myrule"])
3+
# delete a bucket access policy rule by bucket id
4+
client.delete_buckets_bucket_access_policies_rules(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"], names=["myrule"])
5+
# delete a bucket access policy rule by policy name
6+
client.delete_buckets_bucket_access_policies_rules(policy_names=["bkt1/access-policy"], names=["myrule"])
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# delete a bucket cross-origin resource sharing policy by bucket name
2+
client.delete_buckets_cross_origin_resource_sharing_policies(bucket_names=["bkt1"])
3+
# delete a bucket cross-origin resource sharing policy by bucket id
4+
client.delete_buckets_cross_origin_resource_sharing_policies(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"])
5+
# delete a bucket cross-origin resource sharing policy by name
6+
client.delete_buckets_cross_origin_resource_sharing_policies(names=["bkt1/cors-policy"])
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# delete a bucket cross-origin resource sharing policy rule by bucket name
2+
client.delete_buckets_cross_origin_resource_sharing_policies_rules(bucket_names=["bkt1"], names=["myrule"])
3+
# delete a bucket cross-origin resource sharing policy rule by bucket id
4+
client.delete_buckets_cross_origin_resource_sharing_policies_rules(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"], names=["myrule"])
5+
# delete a bucket cross-origin resource sharing policy rule by policy name
6+
client.delete_buckets_cross_origin_resource_sharing_policies_rules(policy_names=["bkt1/cors-policy"], names=["myrule"])
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# list bucket access policy by bucket id
2+
res = client.get_buckets_bucket_access_policies(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"])
3+
print(res)
4+
if type(res) == pypureclient.responses.ValidResponse:
5+
print(list(res.items))
6+
# list bucket access policy by bucket name
7+
res = client.get_buckets_bucket_access_policies(bucket_names=["bkt1"])
8+
print(res)
9+
if type(res) == pypureclient.responses.ValidResponse:
10+
print(list(res.items))
11+
# list bucket access policy by policy name
12+
res = client.get_buckets_bucket_access_policies(names=["bkt1/access-policy"])
13+
print(res)
14+
if type(res) == pypureclient.responses.ValidResponse:
15+
print(list(res.items))
16+
# Other valid fields: continuation_token, filter, limit, offset, sort
17+
# See section "Common Fields" for examples
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# list all bucket access policy rules by bucket id
2+
res = client.get_buckets_bucket_access_policies_rules(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"])
3+
print(res)
4+
if type(res) == pypureclient.responses.ValidResponse:
5+
print(list(res.items))
6+
# list all bucket access policy rules by bucket name
7+
res = client.get_buckets_bucket_access_policies_rules(bucket_names=["bkt1"])
8+
print(res)
9+
if type(res) == pypureclient.responses.ValidResponse:
10+
print(list(res.items))
11+
# list all bucket access policy rules by policy name
12+
res = client.get_buckets_bucket_access_policies_rules(policy_names=["bkt1/access-policy"])
13+
print(res)
14+
if type(res) == pypureclient.responses.ValidResponse:
15+
print(list(res.items))
16+
# list specific bucket access policy rule
17+
res = client.get_buckets_bucket_access_policies_rules(policy_names=["bkt1/access-policy"], names=["myrule"])
18+
print(res)
19+
if type(res) == pypureclient.responses.ValidResponse:
20+
print(list(res.items))
21+
# Other valid fields: continuation_token, filter, limit, offset, sort
22+
# See section "Common Fields" for examples
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# list bucket cross-origin resource sharing policy by bucket id
2+
res = client.get_buckets_cross_origin_resource_sharing_policies(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"])
3+
print(res)
4+
if type(res) == pypureclient.responses.ValidResponse:
5+
print(list(res.items))
6+
# list bucket cross-origin resource sharing policy by bucket name
7+
res = client.get_buckets_cross_origin_resource_sharing_policies(bucket_names=["bkt1"])
8+
print(res)
9+
if type(res) == pypureclient.responses.ValidResponse:
10+
print(list(res.items))
11+
# list bucket cross-origin resource sharing policy by policy name
12+
res = client.get_buckets_cross_origin_resource_sharing_policies(names=["bkt1/cors-policy"])
13+
print(res)
14+
if type(res) == pypureclient.responses.ValidResponse:
15+
print(list(res.items))
16+
# Other valid fields: continuation_token, filter, limit, offset, sort
17+
# See section "Common Fields" for examples
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# list all bucket cross-origin resource sharing policy rules by bucket id
2+
res = client.get_buckets_cross_origin_resource_sharing_policies_rules(bucket_ids=["28674514-e27d-48b3-ae81-d3d2e868f647"])
3+
print(res)
4+
if type(res) == pypureclient.responses.ValidResponse:
5+
print(list(res.items))
6+
# list all bucket cross-origin resource sharing policy rules by bucket name
7+
res = client.get_buckets_cross_origin_resource_sharing_policies_rules(bucket_names=["bkt1"])
8+
print(res)
9+
if type(res) == pypureclient.responses.ValidResponse:
10+
print(list(res.items))
11+
# list all bucket cross-origin resource sharing policy rules by policy name
12+
res = client.get_buckets_cross_origin_resource_sharing_policies_rules(policy_names=["bkt1/cors-policy"])
13+
print(res)
14+
if type(res) == pypureclient.responses.ValidResponse:
15+
print(list(res.items))
16+
# list specific bucket cross-origin resource sharing policy rule
17+
res = client.get_buckets_cross_origin_resource_sharing_policies_rules(policy_names=["bkt1/cors-policy"], names=["myrule"])
18+
print(res)
19+
if type(res) == pypureclient.responses.ValidResponse:
20+
print(list(res.items))
21+
# Other valid fields: continuation_token, filter, limit, offset, sort
22+
# See section "Common Fields" for examples
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pypureclient.flashblade import ActiveDirectoryPatch
2+
3+
# Change existing Active Directory account LDAP, global catalog and kerberos servers, encryption types, and
4+
# service principal names.
5+
# Can alternatively supply fqdns instead of service_principal_names
6+
ad_config = ActiveDirectoryPatch(
7+
directory_servers=["ldap.my-corporation.com", "[email protected]"],
8+
kerberos_servers=["kdc.my-corporation.com"],
9+
global_catalog_servers=["gc.my-corporation.com", "[email protected]"],
10+
encryption_types=["aes256-cts-hmac-sha1-96"],
11+
service_principal_names=["nfs/vip2.my-array.my-corporation.com"],
12+
)
13+
res = client.patch_active_directory(names=["test-config"], active_directory=ad_config)
14+
print(res)
15+
if type(res) == pypureclient.responses.ValidResponse:
16+
print(list(res.items))
17+
18+
# Move existing Active Directory account to a different Join OU
19+
ad_config = ActiveDirectoryPatch(join_ou="OU=FakeOU")
20+
res = client.patch_active_directory(names=["test-config"], active_directory=ad_config)
21+
print(res)
22+
if type(res) == pypureclient.responses.ValidResponse:
23+
print(list(res.items))
24+
25+
# Other valid fields: ids
26+
# See section "Common Fields" for examples
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from pypureclient.flashblade import Bucket, ObjectLockConfigRequestBody, PublicAccessConfig
2+
3+
# Destroy the bucket named "mybucket", and also suspend versioning
4+
res = client.patch_buckets(names=["mybucket"],
5+
bucket=Bucket(destroyed=True, versioning="suspended"))
6+
print(res)
7+
if type(res) == pypureclient.responses.ValidResponse:
8+
print(list(res.items))
9+
10+
# Recover the bucket "mybucket", and also enable versioning
11+
res = client.patch_buckets(names=["mybucket"],
12+
bucket=Bucket(destroyed=False, versioning="enabled"))
13+
print(res)
14+
if type(res) == pypureclient.responses.ValidResponse:
15+
print(list(res.items))
16+
17+
# Update the quota settings for "mybucket". Enable a hard limit (i.e. enforced)
18+
# quota of 10G for this bucket.
19+
res = client.patch_buckets(names=["mybucket"],
20+
bucket=Bucket(quota_limit=str(10*1024*1024*1024),
21+
hard_limit_enabled=True))
22+
print(res)
23+
if type(res) == pypureclient.responses.ValidResponse:
24+
print(list(res.items))
25+
26+
# Reduce the hard limit quota for "mybucket" to 1G while ignoring its current usage (i.e.
27+
# the operation should not fail due to the bucket's size currently being greater than 1G)
28+
res = client.patch_buckets(names=["mybucket"],
29+
bucket=Bucket(quota_limit=str(1*1024*1024*1024)),
30+
ignore_usage=True)
31+
print(res)
32+
if type(res) == pypureclient.responses.ValidResponse:
33+
print(list(res.items))
34+
35+
# Clear the quota limit for "mybucket"
36+
res = client.patch_buckets(names=["mybucket"],
37+
bucket=Bucket(quota_limit='',))
38+
print(res)
39+
if type(res) == pypureclient.responses.ValidResponse:
40+
print(list(res.items))
41+
42+
# Enable object lock for "mybucket"
43+
res = client.patch_buckets(names=["mybucket"],
44+
bucket=Bucket(object_lock_config=ObjectLockConfigRequestBody(enabled=True)))
45+
print(res)
46+
if type(res) == pypureclient.responses.ValidResponse:
47+
print(list(res.items))
48+
49+
# Change default retention to 1 day and default retention mode to "compliance" for "mybucket".
50+
res = client.patch_buckets(names=["mybucket"],
51+
bucket=Bucket(object_lock_config=ObjectLockConfigRequestBody(
52+
default_retention=86400000, # 1 day in ms
53+
default_retention_mode="compliance")))
54+
print(res)
55+
if type(res) == pypureclient.responses.ValidResponse:
56+
print(list(res.items))
57+
58+
# Change retention lock to "ratcheted" to prevent the level of locked objects protection
59+
# from being decreased and to disable manual eradication of the bucket for "mybucket".
60+
res = client.patch_buckets(names=["mybucket"],
61+
bucket=Bucket(retention_lock="ratcheted"))
62+
print(res)
63+
if type(res) == pypureclient.responses.ValidResponse:
64+
print(list(res.items))
65+
66+
# Freeze locked objects to prevent object overwrite after object lock is enabled for "mybucket".
67+
res = client.patch_buckets(names=["mybucket2"],
68+
bucket=Bucket(object_lock_config=ObjectLockConfigRequestBody(freeze_locked_objects=True)))
69+
print(res)
70+
if type(res) == pypureclient.responses.ValidResponse:
71+
print(list(res.items))
72+
73+
# Disable block new public policies for "mybucket".
74+
res = client.patch_buckets(names=["mybucket"],
75+
bucket=Bucket(public_access_config=PublicAccessConfig(block_new_public_policies=False)))
76+
print(res)
77+
if type(res) == pypureclient.responses.ValidResponse:
78+
print(list(res.items))
79+
80+
# Disable block public access for "mybucket".
81+
res = client.patch_buckets(names=["mybucket"],
82+
bucket=Bucket(public_access_config=PublicAccessConfig(block_public_access=False)))
83+
print(res)
84+
if type(res) == pypureclient.responses.ValidResponse:
85+
print(list(res.items))
86+
87+
# Block new public policies and public access for "mybucket".
88+
res = client.patch_buckets(names=["mybucket"],
89+
bucket=Bucket(public_access_config=PublicAccessConfig(
90+
block_new_public_policies=True,
91+
block_public_access=True)))
92+
print(res)
93+
if type(res) == pypureclient.responses.ValidResponse:
94+
print(list(res.items))
95+
96+
# Other valid fields: ids
97+
# See section "Common Fields" for examples

0 commit comments

Comments
 (0)