This operation applies only to Amazon Rekognition Custom Labels.
Attaches a project policy to a Amazon Rekognition Custom Labels project in a trusting AWS account. A project policy specifies that a trusted AWS account can copy a model version from a trusting AWS account to a project in the trusted AWS account. To copy a model version you use the CopyProjectVersion operation. Only applies to Custom Labels projects.
For more information about the format of a project policy document, see Attaching a project policy (SDK) in the Amazon Rekognition Custom Labels Developer Guide.
The response from PutProjectPolicy is a revision ID for the project policy. You can attach multiple project policies to a project. You can also update an existing project policy by specifying the policy revision ID of the existing policy.
To remove a project policy from a project, call DeleteProjectPolicy. To get a list of project policies attached to a project, call ListProjectPolicies.
You copy a model version by calling CopyProjectVersion.
This operation requires permissions to perform the rekognition:PutProjectPolicy action.
Parameters:
-
project_arn
(ProjectArn)
–
The Amazon Resource Name (ARN) of the project that the project policy is attached to.
-
policy_name
(ProjectPolicyName)
–
-
policy_revision_id
(Optional[ProjectPolicyRevisionId], default:
None
)
–
The revision ID for the Project Policy. Each time you modify a policy, Amazon Rekognition Custom Labels generates and assigns a new PolicyRevisionId and then deletes the previous version of the policy.
-
policy_document
(ProjectPolicyDocument)
–
A resource policy to add to the model. The policy is a JSON structure that contains one or more statements that define the policy. The policy must follow the IAM syntax. For more information about the contents of a JSON policy document, see IAM JSON policy reference.
Raises:
-
AccessDeniedException
–
You are not authorized to perform the action.
-
InternalServerError
–
Amazon Rekognition experienced a service issue. Try your call again.
-
InvalidParameterException
–
Input parameter violated a constraint. Validate your parameter before calling the API operation again.
-
InvalidPolicyRevisionIdException
–
The supplied revision id for the project policy is invalid.
-
LimitExceededException
–
An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: StartLabelDetection) will raise a LimitExceededException exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit.
-
MalformedPolicyDocumentException
–
The format of the project policy document that you supplied to PutProjectPolicy is incorrect.
-
ProvisionedThroughputExceededException
–
The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.
-
ResourceAlreadyExistsException
–
A resource with the specified ID already exists.
-
ResourceNotFoundException
–
The resource specified in the request cannot be found.
-
ServiceQuotaExceededException
–
The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide.
-
ThrottlingException
–
Amazon Rekognition is temporarily unable to process the request. Try your call again.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
PutProjectPolicy
This operation attaches a project policy to a Amazon Rekognition Custom Labels project in a trusting AWS account.
>>> await client.put_project_policy(project_arn='arn:aws:rekognition:us-east-1:111122223333:project/my-sdk-project/1656557051929', policy_name='SamplePolicy', policy_revision_id='0123456789abcdef', policy_document='\'{"Version":"2012-10-17","Statement":[{"Effect":"ALLOW","Principal":{"AWS":"principal"},"Action":"rekognition:CopyProjectVersion","Resource":"arn:aws:rekognition:us-east-1:123456789012:project/my-sdk-project/version/DestinationVersionName/1627045542080"}]}\'')
Source code in docs_src/capo_rekognition/_services/async_rekognition.py
| async def put_project_policy(
self,
project_arn: "capo_rekognition.types.project_arn.ProjectArn",
policy_name: "capo_rekognition.types.project_policy_name.ProjectPolicyName",
policy_document: "capo_rekognition.types.project_policy_document.ProjectPolicyDocument",
*,
config_overrides: Optional[AsyncRekognitionClientConfig] = None,
policy_revision_id: Optional[
"capo_rekognition.types.project_policy_revision_id.ProjectPolicyRevisionId"
] = None,
) -> "capo_rekognition.types.put_project_policy_response.PutProjectPolicyResponse":
r"""<note> <p>This operation applies only to Amazon Rekognition Custom Labels.</p> </note> <p>Attaches a project policy to a Amazon Rekognition Custom Labels project in a trusting AWS account. A project policy specifies that a trusted AWS account can copy a model version from a trusting AWS account to a project in the trusted AWS account. To copy a model version you use the <a>CopyProjectVersion</a> operation. Only applies to Custom Labels projects.</p> <p>For more information about the format of a project policy document, see Attaching a project policy (SDK) in the <i>Amazon Rekognition Custom Labels Developer Guide</i>. </p> <p>The response from <code>PutProjectPolicy</code> is a revision ID for the project policy. You can attach multiple project policies to a project. You can also update an existing project policy by specifying the policy revision ID of the existing policy.</p> <p>To remove a project policy from a project, call <a>DeleteProjectPolicy</a>. To get a list of project policies attached to a project, call <a>ListProjectPolicies</a>. </p> <p>You copy a model version by calling <a>CopyProjectVersion</a>.</p> <p>This operation requires permissions to perform the <code>rekognition:PutProjectPolicy</code> action.</p>
Args:
project_arn: <p>The Amazon Resource Name (ARN) of the project that the project policy is attached to.</p>
policy_name: <p>A name for the policy.</p>
policy_revision_id: <p>The revision ID for the Project Policy. Each time you modify a policy, Amazon Rekognition Custom Labels generates and assigns a new <code>PolicyRevisionId</code> and then deletes the previous version of the policy.</p>
policy_document: <p>A resource policy to add to the model. The policy is a JSON structure that contains one or more statements that define the policy. The policy must follow the IAM syntax. For more information about the contents of a JSON policy document, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html">IAM JSON policy reference</a>. </p>
Raises:
capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
capo_rekognition.errors.invalid_policy_revision_id_exception.InvalidPolicyRevisionIdException: <p>The supplied revision id for the project policy is invalid.</p>
capo_rekognition.errors.limit_exceeded_exception.LimitExceededException: <p>An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: <code>StartLabelDetection</code>) will raise a <code>LimitExceededException</code> exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit. </p>
capo_rekognition.errors.malformed_policy_document_exception.MalformedPolicyDocumentException: <p>The format of the project policy document that you supplied to <code>PutProjectPolicy</code> is incorrect. </p>
capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
capo_rekognition.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>A resource with the specified ID already exists.</p>
capo_rekognition.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request cannot be found.</p>
capo_rekognition.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p></p> <p>The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>
capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
PutProjectPolicy
This operation attaches a project policy to a Amazon Rekognition Custom Labels project in a trusting AWS account.
>>> await client.put_project_policy(project_arn='arn:aws:rekognition:us-east-1:111122223333:project/my-sdk-project/1656557051929', policy_name='SamplePolicy', policy_revision_id='0123456789abcdef', policy_document='\'{"Version":"2012-10-17","Statement":[{"Effect":"ALLOW","Principal":{"AWS":"principal"},"Action":"rekognition:CopyProjectVersion","Resource":"arn:aws:rekognition:us-east-1:123456789012:project/my-sdk-project/version/DestinationVersionName/1627045542080"}]}\'')
"""
async def _handler(
req: "AsyncOperationRequest[capo_rekognition.types.put_project_policy_request.PutProjectPolicyRequest]",
) -> AsyncOperationResponse[
"capo_rekognition.types.put_project_policy_response.PutProjectPolicyResponse"
]:
import capo_rekognition._operations.rekognition_service.put_project_policy
(
output,
http_response,
) = await capo_rekognition._operations.rekognition_service.put_project_policy.async_put_project_policy(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutProjectPolicy")
)
input_: capo_rekognition.types.put_project_policy_request.PutProjectPolicyRequest = {
"project_arn": project_arn,
"policy_name": policy_name,
"policy_document": policy_document,
}
if policy_revision_id is not None:
input_["policy_revision_id"] = policy_revision_id
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|