PolicyRestClient class

Base class that should be used (derived from) to make requests to VSS REST apis

Extends

Constructors

PolicyRestClient(IVssRestClientOptions)

Properties

RESOURCE_AREA_ID

Methods

createPolicyConfiguration(PolicyConfiguration, string)

Create a policy configuration of a given policy type.

deletePolicyConfiguration(string, number)

Delete a policy configuration by its ID.

getPolicyConfiguration(string, number)

Get a policy configuration by its ID.

getPolicyConfigurationRevision(string, number, number)

Retrieve a specific revision of a given policy by ID.

getPolicyConfigurationRevisions(string, number, number, number)

Retrieve all revisions for a given policy.

getPolicyConfigurations(string, string, string)

Get a list of policy configurations in a project.

getPolicyEvaluation(string, string)

Gets the present evaluation state of a policy.

getPolicyEvaluations(string, string, boolean, number, number)

Retrieves a list of all the policy evaluation statuses for a specific pull request.

getPolicyType(string, string)

Retrieve a specific policy type by ID.

getPolicyTypes(string)

Retrieve all available policy types.

requeuePolicyEvaluation(string, string)

Requeue the policy evaluation.

updatePolicyConfiguration(PolicyConfiguration, string, number)

Update a policy configuration by its ID.

Constructor Details

PolicyRestClient(IVssRestClientOptions)

new PolicyRestClient(options: IVssRestClientOptions)

Parameters

Property Details

RESOURCE_AREA_ID

static RESOURCE_AREA_ID: string

Property Value

string

Method Details

createPolicyConfiguration(PolicyConfiguration, string)

Create a policy configuration of a given policy type.

function createPolicyConfiguration(configuration: PolicyConfiguration, project: string): Promise<PolicyConfiguration>

Parameters

configuration
PolicyConfiguration

The policy configuration to create.

project

string

Project ID or project name

Returns

deletePolicyConfiguration(string, number)

Delete a policy configuration by its ID.

function deletePolicyConfiguration(project: string, configurationId: number): Promise<void>

Parameters

project

string

Project ID or project name

configurationId

number

ID of the policy configuration to delete.

Returns

Promise<void>

getPolicyConfiguration(string, number)

Get a policy configuration by its ID.

function getPolicyConfiguration(project: string, configurationId: number): Promise<PolicyConfiguration>

Parameters

project

string

Project ID or project name

configurationId

number

ID of the policy configuration

Returns

getPolicyConfigurationRevision(string, number, number)

Retrieve a specific revision of a given policy by ID.

function getPolicyConfigurationRevision(project: string, configurationId: number, revisionId: number): Promise<PolicyConfiguration>

Parameters

project

string

Project ID or project name

configurationId

number

The policy configuration ID.

revisionId

number

The revision ID.

Returns

getPolicyConfigurationRevisions(string, number, number, number)

Retrieve all revisions for a given policy.

function getPolicyConfigurationRevisions(project: string, configurationId: number, top?: number, skip?: number): Promise<PolicyConfiguration[]>

Parameters

project

string

Project ID or project name

configurationId

number

The policy configuration ID.

top

number

The number of revisions to retrieve.

skip

number

The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.

Returns

Promise<PolicyConfiguration[]>

getPolicyConfigurations(string, string, string)

Get a list of policy configurations in a project.

function getPolicyConfigurations(project: string, scope?: string, policyType?: string): Promise<PagedList<PolicyConfiguration>>

Parameters

project

string

Project ID or project name

scope

string

[Provided for legacy reasons] The scope on which a subset of policies is defined.

policyType

string

Filter returned policies to only this type

Returns

getPolicyEvaluation(string, string)

Gets the present evaluation state of a policy.

function getPolicyEvaluation(project: string, evaluationId: string): Promise<PolicyEvaluationRecord>

Parameters

project

string

Project ID or project name

evaluationId

string

ID of the policy evaluation to be retrieved.

Returns

getPolicyEvaluations(string, string, boolean, number, number)

Retrieves a list of all the policy evaluation statuses for a specific pull request.

function getPolicyEvaluations(project: string, artifactId: string, includeNotApplicable?: boolean, top?: number, skip?: number): Promise<PolicyEvaluationRecord[]>

Parameters

project

string

Project ID or project name

artifactId

string

A string which uniquely identifies the target of a policy evaluation.

includeNotApplicable

boolean

Some policies might determine that they do not apply to a specific pull request. Setting this parameter to true will return evaluation records even for policies which don't apply to this pull request.

top

number

The number of policy evaluation records to retrieve.

skip

number

The number of policy evaluation records to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.

Returns

getPolicyType(string, string)

Retrieve a specific policy type by ID.

function getPolicyType(project: string, typeId: string): Promise<PolicyType>

Parameters

project

string

Project ID or project name

typeId

string

The policy ID.

Returns

Promise<PolicyType>

getPolicyTypes(string)

Retrieve all available policy types.

function getPolicyTypes(project: string): Promise<PolicyType[]>

Parameters

project

string

Project ID or project name

Returns

Promise<PolicyType[]>

requeuePolicyEvaluation(string, string)

Requeue the policy evaluation.

function requeuePolicyEvaluation(project: string, evaluationId: string): Promise<PolicyEvaluationRecord>

Parameters

project

string

Project ID or project name

evaluationId

string

ID of the policy evaluation to be retrieved.

Returns

updatePolicyConfiguration(PolicyConfiguration, string, number)

Update a policy configuration by its ID.

function updatePolicyConfiguration(configuration: PolicyConfiguration, project: string, configurationId: number): Promise<PolicyConfiguration>

Parameters

configuration
PolicyConfiguration

The policy configuration to update.

project

string

Project ID or project name

configurationId

number

ID of the existing policy configuration to be updated.

Returns