Policy Management
Managing your policy set
This function allows for various manipulations and retrievals of policy-related data within the system, such as creating, updating, pausing, deleting, testing, and attaching/detaching policies.
Request Parameters
apiKey
: (string) User's API key, used to authenticate the request.action
: (PolicyUpdateAction) An action object containing the type of operation to be performed and any necessary supplementary information.id
: (string) A unique identifier for the request.
Response
Returns a promise that resolves to an object containing:
statusCode
: (200 | 400) The HTTP status code of the operation.response
: An object containing information relevant to the executed operation.
Policy Action: 'create'
The create
action generates a new policy in the system. It creates a unique ID for the policy and the associated API, and stores the policy's data in the UserPoliciesTable and ApiPoliciesTable. It returns the newly created policy's ID in the response.
Required parameters in action
:
policy
: The policy object.label
: The label for the policy.access
: The access level of the policy.
Policy Action: 'update'
The update
action updates an existing policy. It checks the policy ownership, and if the user is authorized, it updates the policy's label or policy object (or both) based on the action parameters.
Required parameters in action
:
id
: The ID of the policy to be updated.label
(optional): The new label for the policy.policy
(optional): The new policy object.
Policy Action: 'delete'
The delete
action deletes an existing policy. It checks if the user is authorized to delete the policy. If authorized, it deletes all associations of the policy from the ApiPoliciesTable and then deletes the policy from the UserPoliciesTable.
Required parameters in action
:
id
: The ID of the policy to be deleted.
Policy Action: 'view'
The view
action retrieves the details of a specific policy. It checks if the user is authorized to view the policy. If authorized, it returns the policy's details in the response.
Required parameters in action
:
id
: The ID of the policy to be viewed.
Policy Action: 'show'
The show
action lists all policies based on the specified access level. It returns all private, public, or all policies depending on the access parameter.
Required parameters in action
:
access
: The access level of the policies to be listed. This can be 'private', 'public', or 'all'.
Policy Action: 'attach'
The attach
action attaches an existing policy to the API key. It checks if the user is authorized and if the policy is not already attached to the API key. If checks pass, it attaches the policy by creating a record in the ApiPoliciesTable.
Required parameters in action
:
id
: The ID of the policy to be attached.
Policy Action: 'detach'
The detach
action detaches an existing policy from the API key. It checks if the policy is currently attached to the API key. If it is, it detaches the policy by removing the association from the ApiPoliciesTable.
Required parameters in action
:
id
: The ID of the policy to be detached.
Policy Action: 'pause'
The pause
action allows to pause or enable a policy. It checks if the user is authorized to perform the operation. If authorized, it updates the state of the policy to 'paused' or 'enabled' based on the enabled
parameter.
Required parameters in action
:
id
: The ID of the policy to be paused/enabled.enabled
: Boolean value indicating whether the policy should be enabled (true
) or paused (false
).
Updated 6 months ago