Package org.azd.policy
Class PolicyApi
- All Implemented Interfaces:
PolicyDetails
PolicyApi class to manage Policy API
-
Constructor Summary
ConstructorDescriptionPolicyApi
(Connection connection) Pass the connection object to work with Policy Api -
Method Summary
Modifier and TypeMethodDescriptioncreatePolicyConfiguration
(String typeId, boolean isEnabled, boolean isBlocking, Map settings) Create a policy configuration of a given policy type.deletePolicyConfiguration
(int configurationId) Delete a policy configuration by its ID.getPolicyConfiguration
(int configurationId) Get a policy configuration by its ID.Get a list of policy configurations in a project.getPolicyConfigurations
(int top, String continuationToken, String policyType) Get a list of policy configurations in a project.getPolicyType
(String typeId) Retrieve a specific policy type by ID.Retrieve all available policy types.updatePolicyConfiguration
(int configurationId, String typeId, boolean isEnabled, boolean isBlocking, Map settings) Update a policy configuration by its ID.Methods inherited from class org.azd.utils.AzDAsyncApi
createAsync
-
Constructor Details
-
PolicyApi
Pass the connection object to work with Policy Api- Parameters:
connection
- Connection object
-
-
Method Details
-
createPolicyConfiguration
public PolicyConfiguration createPolicyConfiguration(String typeId, boolean isEnabled, boolean isBlocking, Map settings) throws AzDException Create a policy configuration of a given policy type.- Specified by:
createPolicyConfiguration
in interfacePolicyDetails
- Parameters:
typeId
- Guid of the policy type.isEnabled
- If set to true the policy will be enabled.isBlocking
- If set to true direct commit will be blocked to the branch specified.settings
- A Map of user specified settings. Check https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/create?view=azure-devops-rest-6.1#examples for more examples and how to configure the policy.- Returns:
- PolicyConfiguration object
PolicyConfiguration
- Throws:
AzDException
- Default Api Exception handler.
-
deletePolicyConfiguration
Delete a policy configuration by its ID.- Specified by:
deletePolicyConfiguration
in interfacePolicyDetails
- Parameters:
configurationId
- ID of the policy configuration to delete.- Throws:
AzDException
- Default Api Exception handler.
-
getPolicyConfiguration
Get a policy configuration by its ID.- Specified by:
getPolicyConfiguration
in interfacePolicyDetails
- Parameters:
configurationId
- ID of the policy configuration- Returns:
- PolicyConfiguration object
PolicyConfiguration
- Throws:
AzDException
- Default Api Exception handler.
-
getPolicyConfigurations
Get a list of policy configurations in a project.- Specified by:
getPolicyConfigurations
in interfacePolicyDetails
- Returns:
- PolicyConfigurations object
PolicyConfigurations
- Throws:
AzDException
- Default Api Exception handler.
-
getPolicyConfigurations
public PolicyConfigurations getPolicyConfigurations(int top, String continuationToken, String policyType) throws AzDException Get a list of policy configurations in a project.- Specified by:
getPolicyConfigurations
in interfacePolicyDetails
- Parameters:
top
- Maximum number of policies to return.continuationToken
- The continuation token used for pagination.policyType
- Filter returned policies to only this type- Returns:
- PolicyConfigurations object
PolicyConfigurations
- Throws:
AzDException
- Default Api Exception handler.
-
updatePolicyConfiguration
public PolicyConfiguration updatePolicyConfiguration(int configurationId, String typeId, boolean isEnabled, boolean isBlocking, Map settings) throws AzDException Update a policy configuration by its ID.- Specified by:
updatePolicyConfiguration
in interfacePolicyDetails
- Parameters:
configurationId
- ID of the existing policy configuration to be updated.typeId
- Guid of the configuration policy type.isEnabled
- If set to true the policy will be enabled.isBlocking
- If set to true direct commit will be blocked to the branch specified.settings
- A Map of user specified settings. Check https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/update?view=azure-devops-rest-6.1#examples for more examples and how to configure the policy.- Returns:
- PolicyConfiguration object
PolicyConfiguration
- Throws:
AzDException
- Default Api Exception handler.
-
getPolicyType
Retrieve a specific policy type by ID.- Specified by:
getPolicyType
in interfacePolicyDetails
- Parameters:
typeId
- Guid of the configuration policy type.- Returns:
- PolicyType object
PolicyType
- Throws:
AzDException
- Default Api Exception handler.
-
getPolicyTypes
Retrieve all available policy types.- Specified by:
getPolicyTypes
in interfacePolicyDetails
- Returns:
- PolicyTypes object
PolicyTypes
- Throws:
AzDException
- Default Api Exception handler.
-