Class ConstraintPolicyOperations

java.lang.Object
co.ankatech.ankasecure.keymanagement.ConstraintPolicyOperations

public final class ConstraintPolicyOperations extends Object
The tenant's constraint policies: the usage, time and payload bounds a capability grant can carry. Obtained from AuthenticatedKeyManagementSdk.constraintPolicies().

 ConstraintPolicyResponse policy = sdk.constraintPolicies().create(
         new CreateConstraintPolicyRequest().name("nightly-batch").maxUsage(1000));
 
  • Method Details

    • list

      Lists constraint policies (GET /tenants/{t}/constraint-policies).
      Parameters:
      query - the page; must not be null
      Returns:
      one page of policies
      Throws:
      KeyManagementSdkException - when the call is refused
    • create

      Creates a constraint policy (POST /tenants/{t}/constraint-policies).
      Parameters:
      request - the policy; must not be null
      Returns:
      the created policy
      Throws:
      KeyManagementSdkException - when the call is refused
    • get

      public ConstraintPolicyResponse get(UUID policyId)
      Reads one constraint policy (GET /tenants/{t}/constraint-policies/{p}).
      Parameters:
      policyId - the policy; must not be null
      Returns:
      the policy
      Throws:
      KeyManagementSdkException - when the call is refused
    • update

      public ConstraintPolicyResponse update(UUID policyId, CreateConstraintPolicyRequest request)
      Updates a constraint policy (PATCH /tenants/{t}/constraint-policies/{p}).
      Parameters:
      policyId - the policy; must not be null
      request - the policy's new values; must not be null
      Returns:
      the updated policy
      Throws:
      KeyManagementSdkException - when the call is refused
    • delete

      public void delete(UUID policyId)
      Deletes a constraint policy (DELETE /tenants/{t}/constraint-policies/{p}).
      Parameters:
      policyId - the policy; must not be null
      Throws:
      KeyManagementSdkException - when a grant still carries the policy (409) or the call is refused
    • versions

      public List<ConstraintPolicyVersionResponse> versions(UUID policyId)
      Lists every version of a policy, oldest first (GET /tenants/{t}/constraint-policies/{p}/versions). Creating a policy writes version 1 and every edit writes the next one; a version never changes.
      Parameters:
      policyId - the policy; must not be null
      Returns:
      the versions, each with how many live grants are pinned to it
      Throws:
      KeyManagementSdkException - when the call is refused
    • version

      public ConstraintPolicyVersionResponse version(UUID policyId, int version)
      Reads one version of a policy (GET /tenants/{t}/constraint-policies/{p}/versions/{v}).
      Parameters:
      policyId - the policy; must not be null
      version - the version number
      Returns:
      the limits and schedule a grant pinned to it enforces
      Throws:
      KeyManagementSdkException - when the call is refused
    • compareVersions

      public ConstraintPolicyVersionComparison compareVersions(UUID baseVersionId, UUID targetVersionId)
      Compares two versions of one policy (GET /tenants/{t}/constraint-policies/versions/compare): the fields whose value differs, each with its base and target value. Two versions of different policies are refused (400).
      Parameters:
      baseVersionId - the base version's id, as versions(UUID) returns it; must not be null
      targetVersionId - the target version's id; must not be null
      Returns:
      the changed fields
      Throws:
      KeyManagementSdkException - when the call is refused