|
| 1 | +import datetime |
| 2 | +from typing import Optional, List, Any, Union |
| 3 | +from .. import serde |
| 4 | + |
| 5 | + |
| 6 | +class CORSRule(serde.Model): |
| 7 | + """ |
| 8 | + The container that stores the CORS rules.Up to 10 CORS rules can be configured for a bucket. The XML message body in a request can be up to 16 KB in size. |
| 9 | + """ |
| 10 | + |
| 11 | + _attribute_map = { |
| 12 | + 'allowed_origins': {'tag': 'xml', 'rename': 'AllowedOrigin', 'type': '[str]'}, |
| 13 | + 'allowed_methods': {'tag': 'xml', 'rename': 'AllowedMethod', 'type': '[str]'}, |
| 14 | + 'allowed_headers': {'tag': 'xml', 'rename': 'AllowedHeader', 'type': '[str]'}, |
| 15 | + 'expose_headers': {'tag': 'xml', 'rename': 'ExposeHeader', 'type': '[str]'}, |
| 16 | + 'max_age_seconds': {'tag': 'xml', 'rename': 'MaxAgeSeconds', 'type': 'int'}, |
| 17 | + } |
| 18 | + |
| 19 | + _xml_map = { |
| 20 | + 'name': 'CORSRule' |
| 21 | + } |
| 22 | + |
| 23 | + def __init__( |
| 24 | + self, |
| 25 | + allowed_origins: Optional[List[str]] = None, |
| 26 | + allowed_methods: Optional[List[str]] = None, |
| 27 | + allowed_headers: Optional[List[str]] = None, |
| 28 | + expose_headers: Optional[List[str]] = None, |
| 29 | + max_age_seconds: Optional[int] = None, |
| 30 | + **kwargs: Any |
| 31 | + ) -> None: |
| 32 | + """ |
| 33 | + allowed_origins (List[str], optional): The origins from which cross-origin requests are allowed. |
| 34 | + allowed_methods (List[str], optional): The methods that you can use in cross-origin requests. |
| 35 | + allowed_headers (List[str], optional): Specifies whether the headers specified by Access-Control-Request-Headers in the OPTIONS preflight request are allowed. Each header specified by Access-Control-Request-Headers must match the value of an AllowedHeader element. You can use only one asterisk (\*) as the wildcard character. |
| 36 | + expose_headers (List[str], optional): The response headers for allowed access requests from applications, such as an XMLHttpRequest object in JavaScript. The asterisk (\*) wildcard character is not supported. |
| 37 | + max_age_seconds (int, optional): The period of time within which the browser can cache the response to an OPTIONS preflight request for the specified resource. Unit: seconds.You can specify only one MaxAgeSeconds element in a CORS rule. |
| 38 | + """ |
| 39 | + super().__init__(**kwargs) |
| 40 | + self.allowed_origins = allowed_origins |
| 41 | + self.allowed_methods = allowed_methods |
| 42 | + self.allowed_headers = allowed_headers |
| 43 | + self.expose_headers = expose_headers |
| 44 | + self.max_age_seconds = max_age_seconds |
| 45 | + |
| 46 | + |
| 47 | +class CORSConfiguration(serde.Model): |
| 48 | + """ |
| 49 | + The container that stores CORS configuration. |
| 50 | + """ |
| 51 | + |
| 52 | + _attribute_map = { |
| 53 | + 'cors_rules': {'tag': 'xml', 'rename': 'CORSRule', 'type': '[CORSRule]'}, |
| 54 | + 'response_vary': {'tag': 'xml', 'rename': 'ResponseVary', 'type': 'bool'}, |
| 55 | + } |
| 56 | + |
| 57 | + _xml_map = { |
| 58 | + 'name': 'CORSConfiguration' |
| 59 | + } |
| 60 | + |
| 61 | + _dependency_map = { |
| 62 | + 'CORSRule': {'new': lambda: CORSRule()}, |
| 63 | + } |
| 64 | + |
| 65 | + def __init__( |
| 66 | + self, |
| 67 | + cors_rules: Optional[List[CORSRule]] = None, |
| 68 | + response_vary: Optional[bool] = None, |
| 69 | + **kwargs: Any |
| 70 | + ) -> None: |
| 71 | + """ |
| 72 | + cors_rules (List[CORSRule], optional): The container that stores CORS rules. Up to 10 rules can be configured for a bucket. |
| 73 | + response_vary (bool, optional): Indicates whether the Vary: Origin header was returned. Default value: false.- true: The Vary: Origin header is returned regardless whether the request is a cross-origin request or whether the cross-origin request succeeds.- false: The Vary: Origin header is not returned. |
| 74 | + """ |
| 75 | + super().__init__(**kwargs) |
| 76 | + self.cors_rules = cors_rules |
| 77 | + self.response_vary = response_vary |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +class PutBucketCorsRequest(serde.RequestModel): |
| 83 | + """ |
| 84 | + The request for the PutBucketCors operation. |
| 85 | + """ |
| 86 | + |
| 87 | + _attribute_map = { |
| 88 | + 'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True}, |
| 89 | + 'cors_configuration': {'tag': 'input', 'position': 'body', 'rename': 'CORSConfiguration', 'type': 'xml'}, |
| 90 | + } |
| 91 | + |
| 92 | + def __init__( |
| 93 | + self, |
| 94 | + bucket: str = None, |
| 95 | + cors_configuration: Optional[CORSConfiguration] = None, |
| 96 | + **kwargs: Any |
| 97 | + ) -> None: |
| 98 | + """ |
| 99 | + bucket (str, required): The name of the bucket. |
| 100 | + cors_configuration (CORSConfiguration, optional): The request body schema. |
| 101 | + """ |
| 102 | + super().__init__(**kwargs) |
| 103 | + self.bucket = bucket |
| 104 | + self.cors_configuration = cors_configuration |
| 105 | + |
| 106 | + |
| 107 | +class PutBucketCorsResult(serde.ResultModel): |
| 108 | + """ |
| 109 | + The request for the PutBucketCors operation. |
| 110 | + """ |
| 111 | + |
| 112 | +class GetBucketCorsRequest(serde.RequestModel): |
| 113 | + """ |
| 114 | + The request for the GetBucketCors operation. |
| 115 | + """ |
| 116 | + |
| 117 | + _attribute_map = { |
| 118 | + 'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True}, |
| 119 | + } |
| 120 | + |
| 121 | + def __init__( |
| 122 | + self, |
| 123 | + bucket: str = None, |
| 124 | + **kwargs: Any |
| 125 | + ) -> None: |
| 126 | + """ |
| 127 | + bucket (str, required): The name of the bucket. |
| 128 | + """ |
| 129 | + super().__init__(**kwargs) |
| 130 | + self.bucket = bucket |
| 131 | + |
| 132 | + |
| 133 | +class GetBucketCorsResult(serde.ResultModel): |
| 134 | + """ |
| 135 | + The request for the GetBucketCors operation. |
| 136 | + """ |
| 137 | + |
| 138 | + _attribute_map = { |
| 139 | + 'cors_configuration': {'tag': 'output', 'position': 'body', 'rename': 'CORSConfiguration', 'type': 'CORSConfiguration,xml'}, |
| 140 | + } |
| 141 | + |
| 142 | + _dependency_map = { |
| 143 | + 'CORSConfiguration': {'new': lambda: CORSConfiguration()}, |
| 144 | + } |
| 145 | + |
| 146 | + def __init__( |
| 147 | + self, |
| 148 | + cors_configuration: Optional[CORSConfiguration] = None, |
| 149 | + **kwargs: Any |
| 150 | + ) -> None: |
| 151 | + """ |
| 152 | + cors_configuration (CORSConfiguration, optional): The container that stores CORS configuration. |
| 153 | + """ |
| 154 | + super().__init__(**kwargs) |
| 155 | + self.cors_configuration = cors_configuration |
| 156 | + |
| 157 | +class DeleteBucketCorsRequest(serde.RequestModel): |
| 158 | + """ |
| 159 | + The request for the DeleteBucketCors operation. |
| 160 | + """ |
| 161 | + |
| 162 | + _attribute_map = { |
| 163 | + 'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True}, |
| 164 | + } |
| 165 | + |
| 166 | + def __init__( |
| 167 | + self, |
| 168 | + bucket: str = None, |
| 169 | + **kwargs: Any |
| 170 | + ) -> None: |
| 171 | + """ |
| 172 | + bucket (str, required): The name of the bucket. |
| 173 | + """ |
| 174 | + super().__init__(**kwargs) |
| 175 | + self.bucket = bucket |
| 176 | + |
| 177 | + |
| 178 | +class DeleteBucketCorsResult(serde.ResultModel): |
| 179 | + """ |
| 180 | + The request for the DeleteBucketCors operation. |
| 181 | + """ |
| 182 | + |
| 183 | +class OptionObjectRequest(serde.RequestModel): |
| 184 | + """ |
| 185 | + The request for the OptionObject operation. |
| 186 | + """ |
| 187 | + |
| 188 | + _attribute_map = { |
| 189 | + 'bucket': {'tag': 'input', 'position': 'host', 'rename': 'bucket', 'type': 'str', 'required': True}, |
| 190 | + 'key': {'tag': 'input', 'position': 'path', 'rename': 'key', 'type': 'str', 'required': True}, |
| 191 | + 'origin': {'tag': 'input', 'position': 'header', 'rename': 'Origin', 'type': 'str'}, |
| 192 | + 'access_control_request_method': {'tag': 'input', 'position': 'header', 'rename': 'Access-Control-Request-Method', 'type': 'str'}, |
| 193 | + 'access_control_request_headers': {'tag': 'input', 'position': 'header', 'rename': 'Access-Control-Request-Headers', 'type': 'str'}, |
| 194 | + } |
| 195 | + |
| 196 | + def __init__( |
| 197 | + self, |
| 198 | + bucket: str = None, |
| 199 | + key: str = None, |
| 200 | + origin: Optional[str] = None, |
| 201 | + access_control_request_method: Optional[str] = None, |
| 202 | + access_control_request_headers: Optional[str] = None, |
| 203 | + **kwargs: Any |
| 204 | + ) -> None: |
| 205 | + """ |
| 206 | + bucket (str, required): The name of the bucket. |
| 207 | + key (str, required): The full path of the object. |
| 208 | + origin (str, optional): The origin of the request. It is used to identify a cross-origin request. You can specify only one Origin header in a cross-origin request. By default, this header is left empty. |
| 209 | + access_control_request_method (str, optional): The method to be used in the actual cross-origin request. You can specify only one Access-Control-Request-Method header in a cross-origin request. By default, this header is left empty. |
| 210 | + access_control_request_headers (str, optional): The custom headers to be sent in the actual cross-origin request. You can configure multiple custom headers in a cross-origin request. Custom headers are separated by commas (,). By default, this header is left empty. |
| 211 | + """ |
| 212 | + super().__init__(**kwargs) |
| 213 | + self.bucket = bucket |
| 214 | + self.key = key |
| 215 | + self.origin = origin |
| 216 | + self.access_control_request_method = access_control_request_method |
| 217 | + self.access_control_request_headers = access_control_request_headers |
| 218 | + |
| 219 | + |
| 220 | +class OptionObjectResult(serde.ResultModel): |
| 221 | + """ |
| 222 | + The request for the OptionObject operation. |
| 223 | + """ |
| 224 | + |
| 225 | + _attribute_map = { |
| 226 | + 'access_control_allow_origin': {'tag': 'output', 'position': 'header', 'rename': 'Access-Control-Allow-Origin', 'type': 'str'}, |
| 227 | + 'access_control_allow_methods': {'tag': 'output', 'position': 'header', 'rename': 'Access-Control-Allow-Methods', 'type': 'str'}, |
| 228 | + 'access_control_allow_headers': {'tag': 'output', 'position': 'header', 'rename': 'Access-Control-Allow-Headers', 'type': 'str'}, |
| 229 | + 'access_control_expose_headers': {'tag': 'output', 'position': 'header', 'rename': 'Access-Control-Expose-Headers', 'type': 'str'}, |
| 230 | + 'access_control_max_age': {'tag': 'output', 'position': 'header', 'rename': 'Access-Control-Max-Age', 'type': 'int'}, |
| 231 | + } |
| 232 | + |
| 233 | + def __init__( |
| 234 | + self, |
| 235 | + access_control_allow_origin: Optional[str] = None, |
| 236 | + access_control_allow_methods: Optional[str] = None, |
| 237 | + access_control_allow_headers: Optional[str] = None, |
| 238 | + access_control_expose_headers: Optional[str] = None, |
| 239 | + access_control_max_age: Optional[int] = None, |
| 240 | + **kwargs: Any |
| 241 | + ) -> None: |
| 242 | + """ |
| 243 | + access_control_allow_origin (str, optional): <no value> |
| 244 | + access_control_allow_methods (str, optional): <no value> |
| 245 | + access_control_allow_headers (str, optional): <no value> |
| 246 | + access_control_expose_headers (str, optional): <no value> |
| 247 | + access_control_max_age (int, optional): <no value> |
| 248 | + """ |
| 249 | + super().__init__(**kwargs) |
| 250 | + self.access_control_allow_origin = access_control_allow_origin |
| 251 | + self.access_control_allow_methods = access_control_allow_methods |
| 252 | + self.access_control_allow_headers = access_control_allow_headers |
| 253 | + self.access_control_expose_headers = access_control_expose_headers |
| 254 | + self.access_control_max_age = access_control_max_age |
0 commit comments