Creates a new version of the specified IoT policy. To update a policy, create a new policy version. A managed policy can have up to five versions. If the policy has five versions, you must use DeletePolicyVersion to delete an existing version before you create a new one.
Optionally, you can set the new version as the policy's default version. The default version is the operative version (that is, the version that is in effect for the certificates to which the policy is attached).
Requires permission to access the CreatePolicyVersion action.
Parameters:
-
policy_name
(PolicyName)
–
-
policy_document
(PolicyDocument)
–
The JSON document that describes the policy. Minimum length of 1. Maximum length of 2048, excluding whitespace.
-
set_as_default
(Optional[SetAsDefault], default:
None
)
–
Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version (that is, the version that is in effect for the certificates to which the policy is attached).
Raises:
Source code in docs_src/capo_iot/_services/async_io_t.py
| async def create_policy_version(
self,
policy_name: "capo_iot.types.policy_name.PolicyName",
policy_document: "capo_iot.types.policy_document.PolicyDocument",
*,
config_overrides: Optional[AsyncIoTClientConfig] = None,
set_as_default: Optional["capo_iot.types.set_as_default.SetAsDefault"] = None,
) -> "capo_iot.types.create_policy_version_response.CreatePolicyVersionResponse":
"""<p>Creates a new version of the specified IoT policy. To update a policy, create a new policy version. A managed policy can have up to five versions. If the policy has five versions, you must use <a>DeletePolicyVersion</a> to delete an existing version before you create a new one.</p> <p>Optionally, you can set the new version as the policy's default version. The default version is the operative version (that is, the version that is in effect for the certificates to which the policy is attached).</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">CreatePolicyVersion</a> action.</p>
Args:
policy_name: <p>The policy name.</p>
policy_document: <p>The JSON document that describes the policy. Minimum length of 1. Maximum length of 2048, excluding whitespace.</p>
set_as_default: <p>Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version (that is, the version that is in effect for the certificates to which the policy is attached).</p>
Raises:
capo_iot.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
capo_iot.errors.malformed_policy_exception.MalformedPolicyException: <p>The policy documentation is not valid.</p>
capo_iot.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
capo_iot.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is temporarily unavailable.</p>
capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
capo_iot.errors.unauthorized_exception.UnauthorizedException: <p>You are not authorized to perform this operation.</p>
capo_iot.errors.versions_limit_exceeded_exception.VersionsLimitExceededException: <p>The number of policy versions exceeds the limit.</p>
capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_iot.types.create_policy_version_request.CreatePolicyVersionRequest]",
) -> AsyncOperationResponse[
"capo_iot.types.create_policy_version_response.CreatePolicyVersionResponse"
]:
import capo_iot._operations.aws_iot_service.create_policy_version
(
output,
http_response,
) = await capo_iot._operations.aws_iot_service.create_policy_version.async_create_policy_version(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreatePolicyVersion")
)
input_: capo_iot.types.create_policy_version_request.CreatePolicyVersionRequest = {
"policy_name": policy_name,
"policy_document": policy_document,
}
if set_as_default is not None:
input_["set_as_default"] = set_as_default
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|