Skip to content

Commit 345859b

Browse files
scottdallamurabryanmacfarlane
authored andcommitted
build/definition properties APIs, with sample (#95)
* build properties apis * build properties sample
1 parent 89fdd9c commit 345859b

3 files changed

Lines changed: 278 additions & 48 deletions

File tree

api/BuildApi.ts

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export interface IBuildApi extends basem.ClientApiBase {
5353
getProjectMetrics(project: string, metricAggregationType?: string, minMetricsTime?: Date): Promise<BuildInterfaces.BuildMetric[]>;
5454
getDefinitionMetrics(project: string, definitionId: number, minMetricsTime?: Date): Promise<BuildInterfaces.BuildMetric[]>;
5555
getBuildOptionDefinitions(project?: string): Promise<BuildInterfaces.BuildOptionDefinition[]>;
56+
getBuildProperties(project: string, buildId: number, filter?: string[]): Promise<any>;
57+
updateBuildProperties(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, buildId: number): Promise<any>;
58+
getDefinitionProperties(project: string, definitionId: number, filter?: string[]): Promise<any>;
59+
updateDefinitionProperties(customHeaders: any, document: VSSInterfaces.JsonPatchDocument, project: string, definitionId: number): Promise<any>;
5660
getBuildReport(project: string, buildId: number, type?: string): Promise<BuildInterfaces.BuildReportMetadata>;
5761
getBuildReportHtmlContent(project: string, buildId: number, type?: string): Promise<NodeJS.ReadableStream>;
5862
getResourceUsage(): Promise<BuildInterfaces.BuildResourceUsage>;
@@ -1770,6 +1774,210 @@ export class BuildApi extends basem.ClientApiBase implements IBuildApi {
17701774
});
17711775
}
17721776

1777+
/**
1778+
* Gets properties for a build.
1779+
*
1780+
* @param {string} project - Project ID or project name
1781+
* @param {number} buildId - The build id.
1782+
* @param {string[]} filter - Filter to specific properties. Defaults to all properties.
1783+
*/
1784+
public async getBuildProperties(
1785+
project: string,
1786+
buildId: number,
1787+
filter?: string[]
1788+
): Promise<any> {
1789+
1790+
return new Promise<any>(async (resolve, reject) => {
1791+
let routeValues: any = {
1792+
project: project,
1793+
buildId: buildId
1794+
};
1795+
1796+
let queryValues: any = {
1797+
filter: filter && filter.join(","),
1798+
};
1799+
1800+
try {
1801+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
1802+
"3.2-preview.1",
1803+
"build",
1804+
"0a6312e9-0627-49b7-8083-7d74a64849c9",
1805+
routeValues,
1806+
queryValues);
1807+
1808+
let url: string = verData.requestUrl;
1809+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
1810+
verData.apiVersion);
1811+
1812+
let res: restm.IRestResponse<any>;
1813+
res = await this.rest.get<any>(url, options);
1814+
1815+
let ret = this.formatResponse(res.result,
1816+
null,
1817+
false);
1818+
1819+
resolve(ret);
1820+
1821+
}
1822+
catch (err) {
1823+
reject(err);
1824+
}
1825+
});
1826+
}
1827+
1828+
/**
1829+
* Updates properties for a build.
1830+
*
1831+
* @param {VSSInterfaces.JsonPatchDocument} document
1832+
* @param {string} project - Project ID or project name
1833+
* @param {number} buildId - The build id.
1834+
*/
1835+
public async updateBuildProperties(
1836+
customHeaders: any,
1837+
document: VSSInterfaces.JsonPatchDocument,
1838+
project: string,
1839+
buildId: number
1840+
): Promise<any> {
1841+
1842+
return new Promise<any>(async (resolve, reject) => {
1843+
let routeValues: any = {
1844+
project: project,
1845+
buildId: buildId
1846+
};
1847+
1848+
customHeaders = customHeaders || {};
1849+
customHeaders["Content-Type"] = "application/json-patch+json";
1850+
1851+
try {
1852+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
1853+
"3.2-preview.1",
1854+
"build",
1855+
"0a6312e9-0627-49b7-8083-7d74a64849c9",
1856+
routeValues);
1857+
1858+
let url: string = verData.requestUrl;
1859+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
1860+
verData.apiVersion);
1861+
options.additionalHeaders = customHeaders;
1862+
1863+
let res: restm.IRestResponse<any>;
1864+
res = await this.rest.update<any>(url, document, options);
1865+
1866+
let ret = this.formatResponse(res.result,
1867+
null,
1868+
false);
1869+
1870+
resolve(ret);
1871+
1872+
}
1873+
catch (err) {
1874+
reject(err);
1875+
}
1876+
});
1877+
}
1878+
1879+
/**
1880+
* Gets properties for a definition.
1881+
*
1882+
* @param {string} project - Project ID or project name
1883+
* @param {number} definitionId - The definition id.
1884+
* @param {string[]} filter - Filter to specific properties. Defaults to all properties.
1885+
*/
1886+
public async getDefinitionProperties(
1887+
project: string,
1888+
definitionId: number,
1889+
filter?: string[]
1890+
): Promise<any> {
1891+
1892+
return new Promise<any>(async (resolve, reject) => {
1893+
let routeValues: any = {
1894+
project: project,
1895+
definitionId: definitionId
1896+
};
1897+
1898+
let queryValues: any = {
1899+
filter: filter && filter.join(","),
1900+
};
1901+
1902+
try {
1903+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
1904+
"3.2-preview.1",
1905+
"build",
1906+
"d9826ad7-2a68-46a9-a6e9-677698777895",
1907+
routeValues,
1908+
queryValues);
1909+
1910+
let url: string = verData.requestUrl;
1911+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
1912+
verData.apiVersion);
1913+
1914+
let res: restm.IRestResponse<any>;
1915+
res = await this.rest.get<any>(url, options);
1916+
1917+
let ret = this.formatResponse(res.result,
1918+
null,
1919+
false);
1920+
1921+
resolve(ret);
1922+
1923+
}
1924+
catch (err) {
1925+
reject(err);
1926+
}
1927+
});
1928+
}
1929+
1930+
/**
1931+
* Updates properties for a definition.
1932+
*
1933+
* @param {VSSInterfaces.JsonPatchDocument} document
1934+
* @param {string} project - Project ID or project name
1935+
* @param {number} definitionId - The definition id.
1936+
*/
1937+
public async updateDefinitionProperties(
1938+
customHeaders: any,
1939+
document: VSSInterfaces.JsonPatchDocument,
1940+
project: string,
1941+
definitionId: number
1942+
): Promise<any> {
1943+
1944+
return new Promise<any>(async (resolve, reject) => {
1945+
let routeValues: any = {
1946+
project: project,
1947+
definitionId: definitionId
1948+
};
1949+
1950+
customHeaders = customHeaders || {};
1951+
customHeaders["Content-Type"] = "application/json-patch+json";
1952+
1953+
try {
1954+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
1955+
"3.2-preview.1",
1956+
"build",
1957+
"d9826ad7-2a68-46a9-a6e9-677698777895",
1958+
routeValues);
1959+
1960+
let url: string = verData.requestUrl;
1961+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
1962+
verData.apiVersion);
1963+
options.additionalHeaders = customHeaders;
1964+
1965+
let res: restm.IRestResponse<any>;
1966+
res = await this.rest.update<any>(url, document, options);
1967+
1968+
let ret = this.formatResponse(res.result,
1969+
null,
1970+
false);
1971+
1972+
resolve(ret);
1973+
1974+
}
1975+
catch (err) {
1976+
reject(err);
1977+
}
1978+
});
1979+
}
1980+
17731981
/**
17741982
* Gets report for a build
17751983
*

0 commit comments

Comments
 (0)