|
| 1 | +/* |
| 2 | + * --------------------------------------------------------- |
| 3 | + * Copyright(C) Microsoft Corporation. All rights reserved. |
| 4 | + * --------------------------------------------------------- |
| 5 | + * |
| 6 | + * --------------------------------------------------------- |
| 7 | + * Generated file, DO NOT EDIT |
| 8 | + * --------------------------------------------------------- |
| 9 | + */ |
| 10 | + |
| 11 | +// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 12 | + |
| 13 | +import * as restm from 'typed-rest-client/RestClient'; |
| 14 | +import vsom = require('./VsoClient'); |
| 15 | +import basem = require('./ClientApiBases'); |
| 16 | +import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces'); |
| 17 | +import CIXInterfaces = require("./interfaces/CIXInterfaces"); |
| 18 | +import OperationsInterfaces = require("./interfaces/common/OperationsInterfaces"); |
| 19 | + |
| 20 | +export interface ICixApi extends basem.ClientApiBase { |
| 21 | + getConfigurations(project: string, repositoryType?: string, repositoryId?: string, branch?: string, serviceConnectionId?: string): Promise<CIXInterfaces.ConfigurationFile[]>; |
| 22 | + createProjectConnection(createConnectionInputs: CIXInterfaces.CreatePipelineConnectionInputs, project: string): Promise<CIXInterfaces.PipelineConnection>; |
| 23 | + getDetectedBuildFrameworks(project: string, repositoryType?: string, repositoryId?: string, branch?: string, detectionType?: CIXInterfaces.BuildFrameworkDetectionType, serviceConnectionId?: string): Promise<CIXInterfaces.DetectedBuildFramework[]>; |
| 24 | + createResources(creationParameters: { [key: string] : CIXInterfaces.ResourceCreationParameter; }, project: string): Promise<CIXInterfaces.CreatedResources>; |
| 25 | +} |
| 26 | + |
| 27 | +export class CixApi extends basem.ClientApiBase implements ICixApi { |
| 28 | + constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], options?: VsoBaseInterfaces.IRequestOptions) { |
| 29 | + super(baseUrl, handlers, 'node-Pipelines-api', options); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Gets a list of existing configuration files for the given repository. |
| 34 | + * |
| 35 | + * @param {string} project - Project ID or project name |
| 36 | + * @param {string} repositoryType - The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc. |
| 37 | + * @param {string} repositoryId - The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos) |
| 38 | + * @param {string} branch - The repository branch where to look for the configuration file. |
| 39 | + * @param {string} serviceConnectionId - If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos). |
| 40 | + */ |
| 41 | + public async getConfigurations( |
| 42 | + project: string, |
| 43 | + repositoryType?: string, |
| 44 | + repositoryId?: string, |
| 45 | + branch?: string, |
| 46 | + serviceConnectionId?: string |
| 47 | + ): Promise<CIXInterfaces.ConfigurationFile[]> { |
| 48 | + |
| 49 | + return new Promise<CIXInterfaces.ConfigurationFile[]>(async (resolve, reject) => { |
| 50 | + let routeValues: any = { |
| 51 | + project: project |
| 52 | + }; |
| 53 | + |
| 54 | + let queryValues: any = { |
| 55 | + repositoryType: repositoryType, |
| 56 | + repositoryId: repositoryId, |
| 57 | + branch: branch, |
| 58 | + serviceConnectionId: serviceConnectionId, |
| 59 | + }; |
| 60 | + |
| 61 | + try { |
| 62 | + let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( |
| 63 | + "7.2-preview.1", |
| 64 | + "pipelines", |
| 65 | + "8fc87684-9ebc-4c37-ab92-f4ac4a58cb3a", |
| 66 | + routeValues, |
| 67 | + queryValues); |
| 68 | + |
| 69 | + let url: string = verData.requestUrl!; |
| 70 | + let options: restm.IRequestOptions = this.createRequestOptions('application/json', |
| 71 | + verData.apiVersion); |
| 72 | + |
| 73 | + let res: restm.IRestResponse<CIXInterfaces.ConfigurationFile[]>; |
| 74 | + res = await this.rest.get<CIXInterfaces.ConfigurationFile[]>(url, options); |
| 75 | + |
| 76 | + let ret = this.formatResponse(res.result, |
| 77 | + null, |
| 78 | + true); |
| 79 | + |
| 80 | + resolve(ret); |
| 81 | + |
| 82 | + } |
| 83 | + catch (err) { |
| 84 | + reject(err); |
| 85 | + } |
| 86 | + }); |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Creates a new Pipeline connection between the provider installation and the specified project. Returns the PipelineConnection object created. |
| 91 | + * |
| 92 | + * @param {CIXInterfaces.CreatePipelineConnectionInputs} createConnectionInputs |
| 93 | + * @param {string} project |
| 94 | + */ |
| 95 | + public async createProjectConnection( |
| 96 | + createConnectionInputs: CIXInterfaces.CreatePipelineConnectionInputs, |
| 97 | + project: string |
| 98 | + ): Promise<CIXInterfaces.PipelineConnection> { |
| 99 | + if (project == null) { |
| 100 | + throw new TypeError('project can not be null or undefined'); |
| 101 | + } |
| 102 | + |
| 103 | + return new Promise<CIXInterfaces.PipelineConnection>(async (resolve, reject) => { |
| 104 | + let routeValues: any = { |
| 105 | + }; |
| 106 | + |
| 107 | + let queryValues: any = { |
| 108 | + project: project, |
| 109 | + }; |
| 110 | + |
| 111 | + try { |
| 112 | + let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( |
| 113 | + "7.2-preview.1", |
| 114 | + "pipelines", |
| 115 | + "00df4879-9216-45d5-b38d-4a487b626b2c", |
| 116 | + routeValues, |
| 117 | + queryValues); |
| 118 | + |
| 119 | + let url: string = verData.requestUrl!; |
| 120 | + let options: restm.IRequestOptions = this.createRequestOptions('application/json', |
| 121 | + verData.apiVersion); |
| 122 | + |
| 123 | + let res: restm.IRestResponse<CIXInterfaces.PipelineConnection>; |
| 124 | + res = await this.rest.create<CIXInterfaces.PipelineConnection>(url, createConnectionInputs, options); |
| 125 | + |
| 126 | + let ret = this.formatResponse(res.result, |
| 127 | + null, |
| 128 | + false); |
| 129 | + |
| 130 | + resolve(ret); |
| 131 | + |
| 132 | + } |
| 133 | + catch (err) { |
| 134 | + reject(err); |
| 135 | + } |
| 136 | + }); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Returns a list of build frameworks that best match the given repository based on its contents. |
| 141 | + * |
| 142 | + * @param {string} project - Project ID or project name |
| 143 | + * @param {string} repositoryType - The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc. |
| 144 | + * @param {string} repositoryId - The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos) |
| 145 | + * @param {string} branch - The repository branch to detect build frameworks for. |
| 146 | + * @param {CIXInterfaces.BuildFrameworkDetectionType} detectionType |
| 147 | + * @param {string} serviceConnectionId - If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos). |
| 148 | + */ |
| 149 | + public async getDetectedBuildFrameworks( |
| 150 | + project: string, |
| 151 | + repositoryType?: string, |
| 152 | + repositoryId?: string, |
| 153 | + branch?: string, |
| 154 | + detectionType?: CIXInterfaces.BuildFrameworkDetectionType, |
| 155 | + serviceConnectionId?: string |
| 156 | + ): Promise<CIXInterfaces.DetectedBuildFramework[]> { |
| 157 | + |
| 158 | + return new Promise<CIXInterfaces.DetectedBuildFramework[]>(async (resolve, reject) => { |
| 159 | + let routeValues: any = { |
| 160 | + project: project |
| 161 | + }; |
| 162 | + |
| 163 | + let queryValues: any = { |
| 164 | + repositoryType: repositoryType, |
| 165 | + repositoryId: repositoryId, |
| 166 | + branch: branch, |
| 167 | + detectionType: detectionType, |
| 168 | + serviceConnectionId: serviceConnectionId, |
| 169 | + }; |
| 170 | + |
| 171 | + try { |
| 172 | + let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( |
| 173 | + "7.2-preview.1", |
| 174 | + "pipelines", |
| 175 | + "29a30bab-9efb-4652-bf1b-9269baca0980", |
| 176 | + routeValues, |
| 177 | + queryValues); |
| 178 | + |
| 179 | + let url: string = verData.requestUrl!; |
| 180 | + let options: restm.IRequestOptions = this.createRequestOptions('application/json', |
| 181 | + verData.apiVersion); |
| 182 | + |
| 183 | + let res: restm.IRestResponse<CIXInterfaces.DetectedBuildFramework[]>; |
| 184 | + res = await this.rest.get<CIXInterfaces.DetectedBuildFramework[]>(url, options); |
| 185 | + |
| 186 | + let ret = this.formatResponse(res.result, |
| 187 | + null, |
| 188 | + true); |
| 189 | + |
| 190 | + resolve(ret); |
| 191 | + |
| 192 | + } |
| 193 | + catch (err) { |
| 194 | + reject(err); |
| 195 | + } |
| 196 | + }); |
| 197 | + } |
| 198 | + |
| 199 | + /** |
| 200 | + * @param {{ [key: string] : CIXInterfaces.ResourceCreationParameter; }} creationParameters |
| 201 | + * @param {string} project - Project ID or project name |
| 202 | + */ |
| 203 | + public async createResources( |
| 204 | + creationParameters: { [key: string] : CIXInterfaces.ResourceCreationParameter; }, |
| 205 | + project: string |
| 206 | + ): Promise<CIXInterfaces.CreatedResources> { |
| 207 | + |
| 208 | + return new Promise<CIXInterfaces.CreatedResources>(async (resolve, reject) => { |
| 209 | + let routeValues: any = { |
| 210 | + project: project |
| 211 | + }; |
| 212 | + |
| 213 | + try { |
| 214 | + let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( |
| 215 | + "7.2-preview.1", |
| 216 | + "pipelines", |
| 217 | + "43201899-7690-4870-9c79-ab69605f21ed", |
| 218 | + routeValues); |
| 219 | + |
| 220 | + let url: string = verData.requestUrl!; |
| 221 | + let options: restm.IRequestOptions = this.createRequestOptions('application/json', |
| 222 | + verData.apiVersion); |
| 223 | + |
| 224 | + let res: restm.IRestResponse<CIXInterfaces.CreatedResources>; |
| 225 | + res = await this.rest.create<CIXInterfaces.CreatedResources>(url, creationParameters, options); |
| 226 | + |
| 227 | + let ret = this.formatResponse(res.result, |
| 228 | + null, |
| 229 | + false); |
| 230 | + |
| 231 | + resolve(ret); |
| 232 | + |
| 233 | + } |
| 234 | + catch (err) { |
| 235 | + reject(err); |
| 236 | + } |
| 237 | + }); |
| 238 | + } |
| 239 | + |
| 240 | +} |
0 commit comments