@pulumi/azuredevops
Version:
A Pulumi package for creating and managing Azure DevOps.
192 lines • 7.04 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Workitemquery = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Manages a Work Item Query (WIQL based list / tree query) in Azure DevOps.
*
* A query can live either directly under one of the root areas `Shared Queries` or `My Queries`, or inside another query folder. You must provide exactly one of `area` (either `Shared Queries` or `My Queries`) or `parentId` (an existing folder's ID) when creating a query.
*
* The WIQL (Work Item Query Language) statement is used to define the query logic. See the [WIQL Syntax Reference](https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops) for more information.
*
* ## Example Usage
*
* ### Basic query under Shared Queries
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuredevops from "@pulumi/azuredevops";
*
* const example = new azuredevops.Project("example", {
* name: "Example Project",
* workItemTemplate: "Agile",
* versionControl: "Git",
* visibility: "private",
* });
* const allIssues = new azuredevops.Workitemquery("all_issues", {
* projectId: example.id,
* name: "All Active Issues",
* area: "Shared Queries",
* wiql: `SELECT [System.Id], [System.Title], [System.State]
* FROM WorkItems
* WHERE [System.WorkItemType] = 'Issue'
* AND [System.State] <> 'Closed'
* ORDER BY [System.ChangedDate] DESC
* `,
* });
* ```
*
* ### Query inside a custom folder
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuredevops from "@pulumi/azuredevops";
*
* const example = new azuredevops.Project("example", {
* name: "Example Project",
* workItemTemplate: "Agile",
* versionControl: "Git",
* visibility: "private",
* });
* const teamFolder = new azuredevops.WorkitemqueryFolder("team_folder", {
* projectId: example.id,
* name: "Team",
* area: "Shared Queries",
* });
* const myTeamBugs = new azuredevops.Workitemquery("my_team_bugs", {
* projectId: example.id,
* name: "Team Bugs",
* parentId: teamFolder.id,
* wiql: `SELECT [System.Id], [System.Title], [System.State], [System.AssignedTo]
* FROM WorkItems
* WHERE [System.WorkItemType] = 'Bug'
* AND [System.State] <> 'Closed'
* ORDER BY [System.CreatedDate] DESC
* `,
* });
* ```
*
* ### Applying permissions to a query
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azuredevops from "@pulumi/azuredevops";
* import * as std from "@pulumi/std";
*
* const example = new azuredevops.Project("example", {
* name: "Example Project",
* workItemTemplate: "Agile",
* versionControl: "Git",
* visibility: "private",
* });
* const teamFolder = new azuredevops.WorkitemqueryFolder("team_folder", {
* projectId: example.id,
* name: "Team",
* area: "Shared Queries",
* });
* const myTeamBugs = new azuredevops.Workitemquery("my_team_bugs", {
* projectId: example.id,
* name: "Team Bugs",
* parentId: teamFolder.id,
* wiql: `SELECT [System.Id], [System.Title], [System.State], [System.AssignedTo]
* FROM WorkItems
* WHERE [System.WorkItemType] = 'Bug'
* AND [System.State] <> 'Closed'
* ORDER BY [System.CreatedDate] DESC
* `,
* });
* const example_readers = azuredevops.getGroupOutput({
* projectId: example.id,
* name: "Readers",
* });
* const queryPermissions = new azuredevops.WorkItemQueryPermissions("query_permissions", {
* projectId: example.id,
* path: std.index.format({
* input: "%s/%s",
* args: [
* teamFolder.name,
* myTeamBugs.name,
* ],
* }).result,
* principal: example_readers.apply(example_readers => example_readers.id),
* permissions: {
* Read: "Allow",
* Contribute: "Deny",
* ManagePermissions: "Deny",
* Delete: "Deny",
* },
* });
* ```
*
* ## Relevant Links
*
* * [Azure DevOps REST API - Work Item Query (Queries)](https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/queries?view=azure-devops-rest-7.1)
* * [WIQL Syntax Reference](https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops)
*
* ## PAT Permissions Required
*
* * **Work Items**: Read & Write
*
* ## Import
*
* The resource does not support import.
*/
class Workitemquery extends pulumi.CustomResource {
/**
* Get an existing Workitemquery resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new Workitemquery(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Workitemquery. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Workitemquery.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["area"] = state?.area;
resourceInputs["name"] = state?.name;
resourceInputs["parentId"] = state?.parentId;
resourceInputs["projectId"] = state?.projectId;
resourceInputs["wiql"] = state?.wiql;
}
else {
const args = argsOrState;
if (args?.projectId === undefined && !opts.urn) {
throw new Error("Missing required property 'projectId'");
}
if (args?.wiql === undefined && !opts.urn) {
throw new Error("Missing required property 'wiql'");
}
resourceInputs["area"] = args?.area;
resourceInputs["name"] = args?.name;
resourceInputs["parentId"] = args?.parentId;
resourceInputs["projectId"] = args?.projectId;
resourceInputs["wiql"] = args?.wiql;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Workitemquery.__pulumiType, name, resourceInputs, opts);
}
}
exports.Workitemquery = Workitemquery;
/** @internal */
Workitemquery.__pulumiType = 'azuredevops:index/workitemquery:Workitemquery';
//# sourceMappingURL=workitemquery.js.map