AWS SDK Version 3 for .NET
API Reference

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.

Container for the parameters to the CreatePolicy operation. Creates a Cedar policy and saves it in the specified policy store. You can create either a static policy or a policy linked to a policy template.

Creating a policy causes it to be validated against the schema in the policy store. If the policy doesn't pass validation, the operation fails and the policy isn't stored.

Verified Permissions is eventually consistent. It can take a few seconds for a new or changed element to propagate through the service and be visible in the results of other Verified Permissions operations.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.VerifiedPermissions.AmazonVerifiedPermissionsRequest
      Amazon.VerifiedPermissions.Model.CreatePolicyRequest

Namespace: Amazon.VerifiedPermissions.Model
Assembly: AWSSDK.VerifiedPermissions.dll
Version: 3.x.y.z

Syntax

C#
public class CreatePolicyRequest : AmazonVerifiedPermissionsRequest
         IAmazonWebServiceRequest

The CreatePolicyRequest type exposes the following members

Constructors

NameDescription
Public Method CreatePolicyRequest()

Properties

NameTypeDescription
Public Property ClientToken System.String

Gets and sets the property ClientToken.

Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value..

If you don't provide this value, then Amazon Web Services generates a random one for you.

If you retry the operation with the same ClientToken, but with different parameters, the retry fails with an ConflictException error.

Verified Permissions recognizes a ClientToken for eight hours. After eight hours, the next request with the same parameters performs the operation again regardless of the value of ClientToken.

Public Property Definition Amazon.VerifiedPermissions.Model.PolicyDefinition

Gets and sets the property Definition.

A structure that specifies the policy type and content to use for the new policy. You must include either a static or a templateLinked element. The policy content must be written in the Cedar policy language.

Public Property Name System.String

Gets and sets the property Name.

Specifies a name for the policy that is unique among all policies within the policy store. You can use the name in place of the policy ID in API operations that reference the policy. The name must be prefixed with name/.

If you specify a name that is already associated with another policy in the policy store, you receive a ConflictException error.

Public Property PolicyStoreId System.String

Gets and sets the property PolicyStoreId.

Specifies the PolicyStoreId of the policy store you want to store the policy in.

To specify a policy store, use its ID or alias name. When using an alias name, prefix it with policy-store-alias/. For example:

  • ID: PSEXAMPLEabcdefg111111

  • Alias name: policy-store-alias/example-policy-store

To view aliases, use ListPolicyStoreAliases.

Examples

The following example request creates a static policy with a policy scope that specifies both a principal and a resource. The response includes both the Principal and Resource elements because both were specified in the request policy scope.

To create a static policy


var client = new AmazonVerifiedPermissionsClient();
var response = client.BatchGetPolicy(new BatchGetPolicyRequest 
{
    Requests = new List<BatchGetPolicyInputItem> {
        new BatchGetPolicyInputItem {
            PolicyId = "PWv5M6d5HePx3gVVLKY1nK",
            PolicyStoreId = "ERZeDpRc34dkYZeb6FZRVC"
        },
        new BatchGetPolicyInputItem {
            PolicyId = "LzFn6KgLWvv4Mbegus35jn",
            PolicyStoreId = "ERZeDpRc34dkYZeb6FZRVC"
        },
        new BatchGetPolicyInputItem {
            PolicyId = "77gLjer8H5o3mvrnMGrSL5",
            PolicyStoreId = "ERZeDpRc34dkYZeb6FZRVC"
        }
    }
});

List<BatchGetPolicyErrorItem> errors = response.Errors;
List<BatchGetPolicyOutputItem> results = response.Results;

            

The following example creates a template-linked policy using the specified policy template and associates the specified principal to use with the new template-linked policy.

To create a template-linked policy


var client = new AmazonVerifiedPermissionsClient();
var response = client.BatchGetPolicy(new BatchGetPolicyRequest 
{
    Requests = new List<BatchGetPolicyInputItem> {
        new BatchGetPolicyInputItem {
            PolicyId = "name/example-policy",
            PolicyStoreId = "ERZeDpRc34dkYZeb6FZRVC"
        },
        new BatchGetPolicyInputItem {
            PolicyId = "name/example-policy-2",
            PolicyStoreId = "ERZeDpRc34dkYZeb6FZRVC"
        }
    }
});

List<BatchGetPolicyErrorItem> errors = response.Errors;
List<BatchGetPolicyOutputItem> results = response.Results;

            

Version Information

.NET:
Supported in: 8.0 and newer, Core 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5 and newer, 3.5