Skip to content

Commit d0f7afc

Browse files
stephenmichaelfDanny McCormick
authored andcommitted
Add back Gallery api (#233)
* Fixes. * Cleanup. * Clean.
1 parent be95c4d commit d0f7afc

6 files changed

Lines changed: 4002 additions & 2 deletions

File tree

api/GalleryApi.ts

Lines changed: 3770 additions & 0 deletions
Large diffs are not rendered by default.

api/GalleryCompatHttpClientBase.ts

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
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 * as httpm from 'typed-rest-client/HttpClient';
15+
import vsom = require('./VsoClient');
16+
import basem = require('./ClientApiBases');
17+
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
18+
import GalleryInterfaces = require("./interfaces/GalleryInterfaces");
19+
20+
export interface IGalleryCompatHttpClientBase extends basem.ClientApiBase {
21+
createExtensionJson(extensionPackage: GalleryInterfaces.ExtensionPackage): Promise<GalleryInterfaces.PublishedExtension>;
22+
updateExtensionByIdJson(extensionPackage: GalleryInterfaces.ExtensionPackage, extensionId: string): Promise<GalleryInterfaces.PublishedExtension>;
23+
createExtensionWithPublisherJson(extensionPackage: GalleryInterfaces.ExtensionPackage, publisherName: string): Promise<GalleryInterfaces.PublishedExtension>;
24+
updateExtensionJson(extensionPackage: GalleryInterfaces.ExtensionPackage, publisherName: string, extensionName: string): Promise<GalleryInterfaces.PublishedExtension>;
25+
}
26+
27+
export class GalleryCompatHttpClientBase extends basem.ClientApiBase implements IGalleryCompatHttpClientBase {
28+
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], userAgent?: string, options?: VsoBaseInterfaces.IRequestOptions) {
29+
super(baseUrl, handlers, userAgent, options);
30+
}
31+
32+
/**
33+
* @param {GalleryInterfaces.ExtensionPackage} extensionPackage
34+
*/
35+
public createExtensionJson(
36+
extensionPackage: GalleryInterfaces.ExtensionPackage
37+
): Promise<GalleryInterfaces.PublishedExtension> {
38+
39+
return new Promise<GalleryInterfaces.PublishedExtension>(async (resolve, reject) => {
40+
let routeValues: any = {
41+
};
42+
43+
try {
44+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
45+
"3.1-preview.1",
46+
"gallery",
47+
"a41192c8-9525-4b58-bc86-179fa549d80d",
48+
routeValues);
49+
50+
let url: string = verData.requestUrl;
51+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
52+
verData.apiVersion);
53+
let res: restm.IRestResponse<GalleryInterfaces.PublishedExtension>;
54+
res = await this.rest.create<GalleryInterfaces.PublishedExtension>(url, extensionPackage, options);
55+
56+
let ret = this.formatResponse(res.result,
57+
GalleryInterfaces.TypeInfo.PublishedExtension,
58+
false);
59+
60+
resolve(ret);
61+
62+
}
63+
catch (err) {
64+
reject(err);
65+
}
66+
});
67+
}
68+
69+
/**
70+
* @param {GalleryInterfaces.ExtensionPackage} extensionPackage
71+
* @param {string} extensionId
72+
*/
73+
public updateExtensionByIdJson(
74+
extensionPackage: GalleryInterfaces.ExtensionPackage,
75+
extensionId: string
76+
): Promise<GalleryInterfaces.PublishedExtension> {
77+
78+
return new Promise<GalleryInterfaces.PublishedExtension>(async (resolve, reject) => {
79+
let routeValues: any = {
80+
extensionId: extensionId
81+
};
82+
83+
try {
84+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
85+
"3.1-preview.1",
86+
"gallery",
87+
"a41192c8-9525-4b58-bc86-179fa549d80d",
88+
routeValues);
89+
90+
let url: string = verData.requestUrl;
91+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
92+
verData.apiVersion);
93+
let res: restm.IRestResponse<GalleryInterfaces.PublishedExtension>;
94+
res = await this.rest.replace<GalleryInterfaces.PublishedExtension>(url, extensionPackage, options);
95+
96+
let ret = this.formatResponse(res.result,
97+
GalleryInterfaces.TypeInfo.PublishedExtension,
98+
false);
99+
100+
resolve(ret);
101+
102+
}
103+
catch (err) {
104+
reject(err);
105+
}
106+
});
107+
}
108+
109+
/**
110+
* @param {GalleryInterfaces.ExtensionPackage} extensionPackage
111+
* @param {string} publisherName
112+
*/
113+
public createExtensionWithPublisherJson(
114+
extensionPackage: GalleryInterfaces.ExtensionPackage,
115+
publisherName: string
116+
): Promise<GalleryInterfaces.PublishedExtension> {
117+
118+
return new Promise<GalleryInterfaces.PublishedExtension>(async (resolve, reject) => {
119+
let routeValues: any = {
120+
publisherName: publisherName
121+
};
122+
123+
try {
124+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
125+
"3.1-preview.1",
126+
"gallery",
127+
"e11ea35a-16fe-4b80-ab11-c4cab88a0966",
128+
routeValues);
129+
130+
let url: string = verData.requestUrl;
131+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
132+
verData.apiVersion);
133+
let res: restm.IRestResponse<GalleryInterfaces.PublishedExtension>;
134+
res = await this.rest.create<GalleryInterfaces.PublishedExtension>(url, extensionPackage, options);
135+
136+
let ret = this.formatResponse(res.result,
137+
GalleryInterfaces.TypeInfo.PublishedExtension,
138+
false);
139+
140+
resolve(ret);
141+
142+
}
143+
catch (err) {
144+
reject(err);
145+
}
146+
});
147+
}
148+
149+
/**
150+
* @param {GalleryInterfaces.ExtensionPackage} extensionPackage
151+
* @param {string} publisherName
152+
* @param {string} extensionName
153+
*/
154+
public updateExtensionJson(
155+
extensionPackage: GalleryInterfaces.ExtensionPackage,
156+
publisherName: string,
157+
extensionName: string
158+
): Promise<GalleryInterfaces.PublishedExtension> {
159+
160+
return new Promise<GalleryInterfaces.PublishedExtension>(async (resolve, reject) => {
161+
let routeValues: any = {
162+
publisherName: publisherName,
163+
extensionName: extensionName
164+
};
165+
166+
try {
167+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
168+
"3.1-preview.1",
169+
"gallery",
170+
"e11ea35a-16fe-4b80-ab11-c4cab88a0966",
171+
routeValues);
172+
173+
let url: string = verData.requestUrl;
174+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
175+
verData.apiVersion);
176+
let res: restm.IRestResponse<GalleryInterfaces.PublishedExtension>;
177+
res = await this.rest.replace<GalleryInterfaces.PublishedExtension>(url, extensionPackage, options);
178+
179+
let ret = this.formatResponse(res.result,
180+
GalleryInterfaces.TypeInfo.PublishedExtension,
181+
false);
182+
183+
resolve(ret);
184+
185+
}
186+
catch (err) {
187+
reject(err);
188+
}
189+
});
190+
}
191+
}

api/WebApi.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dashboardm = require('./DashboardApi');
99
import extmgmtm = require("./ExtensionManagementApi");
1010
import featuremgmtm = require("./FeatureManagementApi");
1111
import filecontainerm = require('./FileContainerApi');
12+
import gallerym = require('./GalleryApi');
1213
import gitm = require('./GitApi');
1314
import locationsm = require('./LocationsApi');
1415
import notificationm = require('./NotificationApi');
@@ -218,6 +219,12 @@ export class WebApi {
218219
return new filecontainerm.FileContainerApi(serverUrl, handlers, this.options);
219220
}
220221

222+
public async getGalleryApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): Promise<gallerym.IGalleryApi> {
223+
serverUrl = await this._getResourceAreaUrl(serverUrl || this.serverUrl, gallerym.GalleryApi.RESOURCE_AREA_ID);
224+
handlers = handlers || [this.authHandler];
225+
return new gallerym.GalleryApi(serverUrl, handlers, this.options);
226+
}
227+
221228
public async getGitApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): Promise<gitm.IGitApi> {
222229
serverUrl = await this._getResourceAreaUrl(serverUrl || this.serverUrl, gitm.GitApi.RESOURCE_AREA_ID);
223230
handlers = handlers || [this.authHandler];

api/interfaces/GalleryInterfaces.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,29 @@ export enum PublisherState {
12351235
CertificationRevoked = 8,
12361236
}
12371237

1238+
export enum PublisherState {
1239+
/**
1240+
* No state exists for this publisher.
1241+
*/
1242+
None = 0,
1243+
/**
1244+
* This state indicates that publisher has applied for Marketplace verification (via UI) and still not been certified. This state would be reset once the publisher is verified.
1245+
*/
1246+
VerificationPending = 1,
1247+
/**
1248+
* This state indicates that publisher has applied for Marketplace certification (via UI) and still not been certified. This state would be reset once the publisher is certified.
1249+
*/
1250+
CertificationPending = 2,
1251+
/**
1252+
* This state indicates that publisher had applied for Marketplace certification (via UI) but his/her certification got rejected. This state would be reset if and when the publisher is certified.
1253+
*/
1254+
CertificationRejected = 4,
1255+
/**
1256+
* This state indicates that publisher was certified on the Marketplace, but his/her certification got revoked. This state would never be reset, even after publisher gets re-certified. It would indicate that the publisher certification was revoked at least once.
1257+
*/
1258+
CertificationRevoked = 8,
1259+
}
1260+
12381261
/**
12391262
* The core structure of a QnA item
12401263
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azure-devops-node-api",
33
"description": "Node client for Azure DevOps and TFS REST APIs",
4-
"version": "7.0.0",
4+
"version": "7.1.0",
55
"main": "./WebApi.js",
66
"types": "./WebApi.d.ts",
77
"scripts": {

samples/creation.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function run() {
3535
try
3636
{
3737
const vstsCollectionLevel: vsoNodeApi.WebApi = await common.getWebApi();
38-
38+
3939
/********** Build **********/
4040
printSectionStart("Build");
4141
const buildApi = await vstsCollectionLevel.getBuildApi();
@@ -90,6 +90,15 @@ export async function run() {
9090
console.log(`found ${containers.length} containers`);
9191
}
9292

93+
/********** Gallery **********/
94+
printSectionStart('Gallery - Deployment Level');
95+
const galleryApi = await vstsCollectionLevel.getGalleryApi();
96+
const categories: string[] = await galleryApi.getCategories();
97+
98+
if (categories) {
99+
console.log(`found ${categories.length} categories`);
100+
}
101+
93102
/********** Git **********/
94103
printSectionStart("Git");
95104
const gitApi = await vstsCollectionLevel.getGitApi();

0 commit comments

Comments
 (0)