Sets the cross-origin resource sharing (CORS) configuration on a container so that the container can service cross-origin requests. For example, you might want to enable a request whose origin is http://www.example.com to access your AWS Elemental MediaStore container at my.example.container.com by using the browser's XMLHttpRequest capability.
To enable CORS on a container, you attach a CORS policy to the container. In the CORS policy, you configure rules that identify origins and the HTTP methods that can be executed on your container. The policy can contain up to 398,000 characters. You can add up to 100 rules to a CORS policy. If more than one rule applies, the service uses the first applicable rule listed.
To learn more about CORS, see Cross-Origin Resource Sharing (CORS) in AWS Elemental MediaStore.
Parameters:
-
container_name
(ContainerName)
–
The name of the container that you want to assign the CORS policy to.
-
cors_policy
(CorsPolicy)
–
The CORS policy to apply to the container.
Raises:
Source code in docs_src/capo_mediastore/_services/media_store.py
| def put_cors_policy(
self,
container_name: "capo_mediastore.types.container_name.ContainerName",
cors_policy: "capo_mediastore.types.cors_policy.CorsPolicy",
*,
config_overrides: Optional[MediaStoreClientConfig] = None,
) -> "capo_mediastore.types.put_cors_policy_output.PutCorsPolicyOutput":
"""<p>Sets the cross-origin resource sharing (CORS) configuration on a container so that the container can service cross-origin requests. For example, you might want to enable a request whose origin is http://www.example.com to access your AWS Elemental MediaStore container at my.example.container.com by using the browser's XMLHttpRequest capability.</p> <p>To enable CORS on a container, you attach a CORS policy to the container. In the CORS policy, you configure rules that identify origins and the HTTP methods that can be executed on your container. The policy can contain up to 398,000 characters. You can add up to 100 rules to a CORS policy. If more than one rule applies, the service uses the first applicable rule listed.</p> <p>To learn more about CORS, see <a href="https://docs.aws.amazon.com/mediastore/latest/ug/cors-policy.html">Cross-Origin Resource Sharing (CORS) in AWS Elemental MediaStore</a>.</p>
Args:
container_name: <p>The name of the container that you want to assign the CORS policy to.</p>
cors_policy: <p>The CORS policy to apply to the container. </p>
Raises:
capo_mediastore.errors.container_in_use_exception.ContainerInUseException: <p>The container that you specified in the request already exists or is being updated.</p>
capo_mediastore.errors.container_not_found_exception.ContainerNotFoundException: <p>The container that you specified in the request does not exist.</p>
capo_mediastore.errors.internal_server_error.InternalServerError: <p>The service is temporarily unavailable.</p>
capo_mediastore.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_mediastore.types.put_cors_policy_input.PutCorsPolicyInput]",
) -> OperationResponse[
"capo_mediastore.types.put_cors_policy_output.PutCorsPolicyOutput"
]:
import capo_mediastore._operations.media_store_20170901.put_cors_policy
output, http_response = (
capo_mediastore._operations.media_store_20170901.put_cors_policy.put_cors_policy(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutCorsPolicy")
)
input_: capo_mediastore.types.put_cors_policy_input.PutCorsPolicyInput = {
"container_name": container_name,
"cors_policy": cors_policy,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|