Class PolicyApi

All Implemented Interfaces:
PolicyDetails

public class PolicyApi extends AzDAsyncApi<PolicyApi> implements PolicyDetails
PolicyApi class to manage Policy API
  • Constructor Details

    • PolicyApi

      public PolicyApi(Connection connection)
      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 interface PolicyDetails
      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

      public Void deletePolicyConfiguration(int configurationId) throws AzDException
      Delete a policy configuration by its ID.
      Specified by:
      deletePolicyConfiguration in interface PolicyDetails
      Parameters:
      configurationId - ID of the policy configuration to delete.
      Throws:
      AzDException - Default Api Exception handler.
    • getPolicyConfiguration

      public PolicyConfiguration getPolicyConfiguration(int configurationId) throws AzDException
      Get a policy configuration by its ID.
      Specified by:
      getPolicyConfiguration in interface PolicyDetails
      Parameters:
      configurationId - ID of the policy configuration
      Returns:
      PolicyConfiguration object PolicyConfiguration
      Throws:
      AzDException - Default Api Exception handler.
    • getPolicyConfigurations

      public PolicyConfigurations getPolicyConfigurations() throws AzDException
      Get a list of policy configurations in a project.
      Specified by:
      getPolicyConfigurations in interface PolicyDetails
      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 interface PolicyDetails
      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 interface PolicyDetails
      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

      public PolicyType getPolicyType(String typeId) throws AzDException
      Retrieve a specific policy type by ID.
      Specified by:
      getPolicyType in interface PolicyDetails
      Parameters:
      typeId - Guid of the configuration policy type.
      Returns:
      PolicyType object PolicyType
      Throws:
      AzDException - Default Api Exception handler.
    • getPolicyTypes

      public PolicyTypes getPolicyTypes() throws AzDException
      Retrieve all available policy types.
      Specified by:
      getPolicyTypes in interface PolicyDetails
      Returns:
      PolicyTypes object PolicyTypes
      Throws:
      AzDException - Default Api Exception handler.