Skip to content

Commit 2e484ac

Browse files
zhuxiaolong37huiguangjun
authored andcommitted
add bucket policy
1 parent 6eb6e2c commit 2e484ac

File tree

12 files changed

+1056
-0
lines changed

12 files changed

+1056
-0
lines changed

alibabacloud_oss_v2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .models.bucket_cname import *
2323
from .models.bucket_lifecycle import *
2424
from .models.bucket_cors import *
25+
from .models.bucket_policy import *
2526
from .models.bucket_encryption import *
2627
from .models.bucket_logging import *
2728

alibabacloud_oss_v2/client.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,62 @@ def option_object(self, request: models.OptionObjectRequest, **kwargs
12261226
return operations.option_object(self._client, request, **kwargs)
12271227

12281228

1229+
# bucket policy
1230+
def put_bucket_policy(self, request: models.PutBucketPolicyRequest, **kwargs
1231+
) -> models.PutBucketPolicyResult:
1232+
"""
1233+
Configures a policy for a bucket.
1234+
1235+
Args:
1236+
request (PutBucketPolicyRequest): Request parameters for PutBucketPolicy operation.
1237+
1238+
Returns:
1239+
PutBucketPolicyResult: Response result for PutBucketPolicy operation.
1240+
"""
1241+
return operations.put_bucket_policy(self._client, request, **kwargs)
1242+
1243+
def get_bucket_policy(self, request: models.GetBucketPolicyRequest, **kwargs
1244+
) -> models.GetBucketPolicyResult:
1245+
"""
1246+
Queries the policies configured for a bucket.
1247+
1248+
Args:
1249+
request (GetBucketPolicyRequest): Request parameters for GetBucketPolicy operation.
1250+
1251+
Returns:
1252+
GetBucketPolicyResult: Response result for GetBucketPolicy operation.
1253+
"""
1254+
return operations.get_bucket_policy(self._client, request, **kwargs)
1255+
1256+
1257+
def delete_bucket_policy(self, request: models.DeleteBucketPolicyRequest, **kwargs
1258+
) -> models.DeleteBucketPolicyResult:
1259+
"""
1260+
Deletes a policy for a bucket.
1261+
1262+
Args:
1263+
request (DeleteBucketPolicyRequest): Request parameters for DeleteBucketPolicy operation.
1264+
1265+
Returns:
1266+
DeleteBucketPolicyResult: Response result for DeleteBucketPolicy operation.
1267+
"""
1268+
return operations.delete_bucket_policy(self._client, request, **kwargs)
1269+
1270+
1271+
def get_bucket_policy_status(self, request: models.GetBucketPolicyStatusRequest, **kwargs
1272+
) -> models.GetBucketPolicyStatusResult:
1273+
"""
1274+
Checks whether the current bucket policy allows public access.
1275+
1276+
Args:
1277+
request (GetBucketPolicyStatusRequest): Request parameters for GetBucketPolicyStatus operation.
1278+
1279+
Returns:
1280+
GetBucketPolicyStatusResult: Response result for GetBucketPolicyStatus operation.
1281+
"""
1282+
return operations.get_bucket_policy_status(self._client, request, **kwargs)
1283+
1284+
12291285
# bucket logging
12301286
def put_bucket_logging(self, request: models.PutBucketLoggingRequest, **kwargs
12311287
) -> models.PutBucketLoggingResult:

alibabacloud_oss_v2/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
from .bucket_cname import *
1111
from .bucket_lifecycle import *
1212
from .bucket_cors import *
13+
from .bucket_policy import *
1314
from .bucket_logging import *
1415
from .bucket_encryption import *
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
from typing import Optional, List, Any, Union
2+
from .. import serde
3+
4+
5+
class PolicyStatus(serde.Model):
6+
"""
7+
The container that stores public access information.
8+
"""
9+
10+
_attribute_map = {
11+
'is_public': {'tag': 'xml', 'rename': 'IsPublic', 'type': 'bool'},
12+
}
13+
14+
_xml_map = {
15+
'name': 'PolicyStatus'
16+
}
17+
18+
def __init__(
19+
self,
20+
is_public: Optional[bool] = None,
21+
**kwargs: Any
22+
) -> None:
23+
"""
24+
is_public (bool, optional): Indicates whether the current bucket policy allows public access.truefalse
25+
"""
26+
super().__init__(**kwargs)
27+
self.is_public = is_public
28+
29+
30+
31+
32+
class PutBucketPolicyRequest(serde.RequestModel):
33+
"""
34+
The request for the PutBucketPolicy operation.
35+
"""
36+
37+
_attribute_map = {
38+
'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True},
39+
'body': {'tag': 'input', 'position': 'body', 'rename': 'nop', 'type': 'str', 'required': True},
40+
}
41+
42+
def __init__(
43+
self,
44+
bucket: str = None,
45+
body: Optional[str] = None,
46+
**kwargs: Any
47+
) -> None:
48+
"""
49+
bucket (str, required): The name of the bucket.
50+
body (str, required): The request parameters.
51+
"""
52+
super().__init__(**kwargs)
53+
self.bucket = bucket
54+
self.body = body
55+
56+
57+
class PutBucketPolicyResult(serde.ResultModel):
58+
"""
59+
The request for the PutBucketPolicy operation.
60+
"""
61+
62+
class GetBucketPolicyRequest(serde.RequestModel):
63+
"""
64+
The request for the GetBucketPolicy operation.
65+
"""
66+
67+
_attribute_map = {
68+
'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True},
69+
}
70+
71+
def __init__(
72+
self,
73+
bucket: str = None,
74+
**kwargs: Any
75+
) -> None:
76+
"""
77+
bucket (str, required): The name of the bucket.
78+
"""
79+
super().__init__(**kwargs)
80+
self.bucket = bucket
81+
82+
83+
class GetBucketPolicyResult(serde.ResultModel):
84+
"""
85+
The request for the GetBucketPolicy operation.
86+
"""
87+
88+
_attribute_map = {
89+
'body': {'tag': 'output', 'position': 'body', 'type': 'str'},
90+
}
91+
92+
def __init__(
93+
self,
94+
body: Optional[str] = None,
95+
**kwargs: Any
96+
) -> None:
97+
"""
98+
body (io.ReadCloser, optional): <no value>
99+
"""
100+
super().__init__(**kwargs)
101+
self.body = body
102+
103+
class DeleteBucketPolicyRequest(serde.RequestModel):
104+
"""
105+
The request for the DeleteBucketPolicy operation.
106+
"""
107+
108+
_attribute_map = {
109+
'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True},
110+
}
111+
112+
def __init__(
113+
self,
114+
bucket: str = None,
115+
**kwargs: Any
116+
) -> None:
117+
"""
118+
bucket (str, required): The name of the bucket.
119+
"""
120+
super().__init__(**kwargs)
121+
self.bucket = bucket
122+
123+
124+
class DeleteBucketPolicyResult(serde.ResultModel):
125+
"""
126+
The request for the DeleteBucketPolicy operation.
127+
"""
128+
129+
class GetBucketPolicyStatusRequest(serde.RequestModel):
130+
"""
131+
The request for the GetBucketPolicyStatus operation.
132+
"""
133+
134+
_attribute_map = {
135+
'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str'},
136+
}
137+
138+
def __init__(
139+
self,
140+
bucket: Optional[str] = None,
141+
**kwargs: Any
142+
) -> None:
143+
"""
144+
bucket (str, optional): The name of the bucket.
145+
"""
146+
super().__init__(**kwargs)
147+
self.bucket = bucket
148+
149+
150+
class GetBucketPolicyStatusResult(serde.ResultModel):
151+
"""
152+
The request for the GetBucketPolicyStatus operation.
153+
"""
154+
155+
_attribute_map = {
156+
'policy_status': {'tag': 'output', 'position': 'body', 'rename': 'PolicyStatus', 'type': 'PolicyStatus,xml'},
157+
}
158+
159+
_dependency_map = {
160+
'PolicyStatus': {'new': lambda: PolicyStatus()},
161+
}
162+
163+
def __init__(
164+
self,
165+
policy_status: Optional[PolicyStatus] = None,
166+
**kwargs: Any
167+
) -> None:
168+
"""
169+
policy_status (PolicyStatus, optional): The container that stores public access information.
170+
"""
171+
super().__init__(**kwargs)
172+
self.policy_status = policy_status

alibabacloud_oss_v2/operations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from .bucket_access_monitor import *
88
from .bucket_archive_direct_read import *
99
from .bucket_cname import *
10+
from .bucket_cors import *
11+
from .bucket_policy import *
1012
from .bucket_lifecycle import *
1113
from .bucket_cors import *
1214
from .bucket_logging import *

0 commit comments

Comments
 (0)