Skip to content

Commit 322e031

Browse files
routing rule supports more parameters
1 parent a271ff2 commit 322e031

File tree

8 files changed

+1775
-24
lines changed

8 files changed

+1775
-24
lines changed

alibabacloud_oss_v2/models/bucket_website.py

Lines changed: 363 additions & 5 deletions
Large diffs are not rendered by default.

alibabacloud_oss_v2/models/service.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class ListBucketsRequest(serde.RequestModel):
1616
"max_keys": {"tag": "input", "position": "query", "rename": "max-keys", "type": "int"},
1717
"prefix": {"tag": "input", "position": "query", "rename": "prefix"},
1818
"resource_group_id": {"tag": "input", "position": "header", "rename": "x-oss-resource-group-id"},
19+
"tag_key": {"tag": "input", "position": "query", "rename": "tag-key"},
20+
"tag_value": {"tag": "input", "position": "query", "rename": "tag-value"},
21+
"tagging": {"tag": "input", "position": "query", "rename": "tagging"},
1922
}
2023

2124
def __init__(
@@ -24,6 +27,9 @@ def __init__(
2427
max_keys: Optional[int] = None,
2528
prefix: Optional[str] = None,
2629
resource_group_id: Optional[str] = None,
30+
tag_key: Optional[str] = None,
31+
tag_value: Optional[str] = None,
32+
tagging: Optional[str] = None,
2733
**kwargs: Any
2834
) -> None:
2935
"""
@@ -33,13 +39,21 @@ def __init__(
3339
Valid values: 1 to 1000.
3440
prefix (str, optional): The prefix that the names of returned buckets must contain.
3541
Limits the response to keys that begin with the specified prefix
36-
request_payer (str, optional): The ID of the resource group.
42+
resource_group_id (str, optional): The ID of the resource group.
43+
tag_key (str, optional): A tag key of target buckets. The listing results will only include Buckets that have been tagged with this key.
44+
tag_value (str, optional): A tag value for the target buckets. If this parameter is specified in the request, the tag-key must also be specified.
45+
The listing results will only include Buckets that have been tagged with this key-value pair.
46+
tagging (str, optional): Tag list of target buckets. Only Buckets that match all the key-value pairs in the list will added into the listing results.
47+
The tagging parameter cannot be used with the tag-key and tag-value parameters in a request.
3748
"""
3849
super().__init__(**kwargs)
3950
self.marker = marker
4051
self.max_keys = max_keys
4152
self.prefix = prefix
4253
self.resource_group_id = resource_group_id
54+
self.tag_key = tag_key
55+
self.tag_value = tag_value
56+
self.tagging = tagging
4357

4458

4559
class BucketProperties(serde.Model):

sample/list_buckets.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,20 @@ def main():
3333
for o in page.buckets:
3434
print(f'Bucket: {o.name}, {o.location}, {o.creation_date} {o.resource_group_id}')
3535

36+
37+
# Example with all available parameters configured:
38+
# paginator = client.list_buckets_paginator()
39+
# for page in paginator.iter_page(oss.ListBucketsRequest(
40+
# marker='example-marker', # marker: Sets the starting point for returning results. If not set, results start from the beginning.
41+
# max_keys=100, # max-keys: Specifies the maximum number of buckets to return. Range: 1-1000. Default: 100
42+
# prefix='example-prefix', # prefix: Limits results to bucket names that start with the specified prefix. No filtering if not set.
43+
# resource_group_id='rg-xxxxxx', # x-oss-resource-group-id: The ID of the resource group to which the bucket belongs
44+
# tag_key='environment', # tag-key: Filters results to buckets with the specified tag key
45+
# tag_value='production', # tag-value: Filters results to buckets with the specified tag value. Must be used with tag_key
46+
# tagging='owner:finance' # tagging: Filters results to buckets matching all specified tag key-value pairs. Cannot be used with tag-key/tag-value
47+
# )):
48+
# for o in page.buckets:
49+
# print(f'Bucket with params: {o.name}, {o.location}, {o.creation_date} {o.resource_group_id}')
50+
3651
if __name__ == "__main__":
37-
main()
52+
main()

sample/put_bucket_website.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,87 @@ def main():
110110
redirect_type='External',
111111
host_name='example.com',
112112
),
113+
), oss.RoutingRule(
114+
rule_number=4,
115+
condition=oss.RoutingRuleCondition(
116+
key_prefix_equals='key',
117+
),
118+
redirect=oss.RoutingRuleRedirect(
119+
redirect_type='Mirror',
120+
mirror_url='http://example.com/',
121+
),
122+
lua_config=oss.RoutingRuleLuaConfig(
123+
script='test.lua',
124+
),
125+
), oss.RoutingRule(
126+
rule_number=5,
127+
condition=oss.RoutingRuleCondition(
128+
key_suffix_equals='abc/',
129+
http_error_code_returned_equals=404,
130+
include_headers=[oss.RoutingRuleIncludeHeader(
131+
key='key1',
132+
equals='value1',
133+
), oss.RoutingRuleIncludeHeader(
134+
key='key2',
135+
equals='value2',
136+
)],
137+
key_prefix_equals='key',
138+
),
139+
redirect=oss.RoutingRuleRedirect(
140+
redirect_type='Mirror',
141+
mirror_url='http://example.com/',
142+
mirror_allow_video_snapshot=True,
143+
144+
mirror_taggings=oss.MirrorTaggings(
145+
taggings=[oss.MirrorTagging(
146+
key='tag-key1',
147+
value='tag-value1',
148+
), oss.MirrorTagging(
149+
key='tag-key2',
150+
value='tag-value2',
151+
)],
152+
),
153+
mirror_auth=oss.MirrorAuth(
154+
access_key_id='test-access-key-id',
155+
access_key_secret='test-access-key-secret',
156+
auth_type='S3V4',
157+
region='cn-hangzhou',
158+
),
159+
mirror_dst_region='oss-cn-hangzhou',
160+
mirror_role='test-role',
161+
mirror_using_role=True,
162+
mirror_return_headers=oss.MirrorReturnHeaders(
163+
return_headers=[oss.ReturnHeader(
164+
key='header-key1',
165+
value='header-value1',
166+
), oss.ReturnHeader(
167+
key='header-key2',
168+
value='header-value2',
169+
)],
170+
),
171+
mirror_proxy_pass=False,
172+
mirror_is_express_tunnel=True,
173+
mirror_allow_head_object=True,
174+
transparent_mirror_response_codes='404,500',
175+
mirror_save_oss_meta=True,
176+
mirror_allow_get_image_info=True,
177+
mirror_url_probe='http://probe.example.com/',
178+
mirror_user_last_modified=True,
179+
mirror_switch_all_errors=False,
180+
mirror_multi_alternates=oss.MirrorMultiAlternates(
181+
mirror_multi_alternates=[oss.MirrorMultiAlternate(
182+
mirror_multi_alternate_number=1,
183+
mirror_multi_alternate_url='http://alternate1.example.com/',
184+
mirror_multi_alternate_vpc_id='vpc-alternate-1',
185+
mirror_multi_alternate_dst_region='oss-cn-shanghai',
186+
), oss.MirrorMultiAlternate(
187+
mirror_multi_alternate_number=2,
188+
mirror_multi_alternate_url='http://alternate2.example.com/',
189+
mirror_multi_alternate_vpc_id='vpc-alternate-2',
190+
mirror_multi_alternate_dst_region='oss-cn-beijing',
191+
)],
192+
),
193+
),
113194
)],
114195
),
115196
),

0 commit comments

Comments
 (0)