AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
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.
For .NET Core this operation is only available in asynchronous form. Please refer to PutProjectPolicyAsync.
Namespace: Amazon.Rekognition
Assembly: AWSSDK.Rekognition.dll
Version: 3.x.y.z
public virtual PutProjectPolicyResponse PutProjectPolicy( PutProjectPolicyRequest request )
Container for the necessary parameters to execute the PutProjectPolicy service method.
| Exception | Condition |
|---|---|
| AccessDeniedException | You are not authorized to perform the action. |
| InternalServerErrorException | 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. |
This operation attaches a project policy to a Amazon Rekognition Custom Labels project in a trusting AWS account.
var client = new AmazonRekognitionClient();
var response = client.PutProjectPolicy(new PutProjectPolicyRequest
{
PolicyDocument = "'{\"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\"}]}'",
PolicyName = "SamplePolicy",
PolicyRevisionId = "0123456789abcdef",
ProjectArn = "arn:aws:rekognition:us-east-1:111122223333:project/my-sdk-project/1656557051929"
});
string policyRevisionId = response.PolicyRevisionId;
.NET Framework:
Supported in: 4.5 and newer, 3.5