Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: data plane view support #209

Merged
merged 30 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
96cdd45
feat: rbac demo
wenytang-ms Jun 5, 2024
3429972
feat: support api server
wenytang-ms Jul 16, 2024
b187b5a
feat: update
wenytang-ms Jul 16, 2024
dfafbed
feat: ready
wenytang-ms Jul 22, 2024
c9320b6
feat: update
wenytang-ms Jul 22, 2024
6a6c8c1
feat: update
wenytang-ms Aug 1, 2024
25a442b
test: update test case
wenytang-ms Aug 1, 2024
224ece0
feat: add feautres
wenytang-ms Aug 1, 2024
48d8519
docs: strings
wenytang-ms Aug 1, 2024
b24677f
test: update
wenytang-ms Aug 1, 2024
c8ab52a
feat: update command
wenytang-ms Aug 1, 2024
7fc4201
feat: change to b type
wenytang-ms Aug 1, 2024
c86d654
feat: adjust treeitem view structure
wenytang-ms Aug 1, 2024
1476178
feat: update
wenytang-ms Aug 2, 2024
0e90e97
feat: update
wenytang-ms Aug 2, 2024
42e823c
feat: separate defines
wenytang-ms Aug 2, 2024
d538370
feat: update
wenytang-ms Aug 2, 2024
06271c8
feat: update
wenytang-ms Aug 2, 2024
d3bf5db
test: add test cases
wenytang-ms Aug 2, 2024
9816f7c
test: add test cases
wenytang-ms Aug 2, 2024
405785a
fix: update the code according to comments
wenytang-ms Aug 13, 2024
a04a3c4
fix: update code according to comments
wenytang-ms Aug 14, 2024
9c5a58f
feat: update code
wenytang-ms Aug 15, 2024
5c8f466
feat: update
wenytang-ms Aug 15, 2024
8246f70
feat: update
wenytang-ms Aug 16, 2024
8ff5a41
fix: update
wenytang-ms Aug 16, 2024
fe2e39b
Merge branch 'dev' into wenyt/auth1
wenytang-ms Aug 22, 2024
70dee3e
test: fix comments and test cases
wenytang-ms Aug 22, 2024
be0ea57
test: update
wenytang-ms Aug 22, 2024
b715df5
fix: update the uistring
wenytang-ms Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 63 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,44 @@
"command": "azure-api-center.selectTenant",
"title": "%azure-api-center.commands.selectTenant.title%",
"category": "Azure API Center"
},
{
"command": "azure-api-center.apiCenterWorkspace.addApis",
"title": "%azure-api-center.commands.apiCenterWorkspace.addApis.title%",
"icon": "$(add)",
"category": "Azure API Center"
},
{
"command": "azure-api-center.apiCenterWorkspace.refresh",
"title": "%azure-api-center.commands.apiCenterTreeView.refresh.title%",
"icon": "$(refresh)",
"category": "Azure API Center"
},
{
"command": "azure-api-center.apiCenterWorkspace.collapse",
"title": "%azure-api-center.commands.apiCenterWorkspace.collapse.title%",
"icon": "$(collapse-all)",
"category": "Azure API Center"
},
{
"command": "azure-api-center.apiCenterWorkspace.removeApi",
"title": "%azure-api-center.commands.apiCenterWorkspace.removeApis.title%",
"icon": "$(close)",
"category": "Azure API Center"
}
],
"views": {
"api-center-treeview": [
{
"id": "apiCenterTreeView",
"name": "API Center",
"name": "%azure-api-center.views.api-center-treeview.controlplane.title%",
"icon": "media/api-center-icon.svg",
"contextualTitle": "Azure API Center"
},
{
"id": "apiCenterWorkspace",
"name": "%azure-api-center.views.api-center-treeview.dataplane.title%",
"visibility": "visible"
}
]
},
Expand All @@ -191,6 +220,21 @@
"command": "azure-api-center.apiCenterTreeView.refresh",
"when": "view == apiCenterTreeView",
"group": "navigation"
},
{
"command": "azure-api-center.apiCenterWorkspace.addApis",
"when": "view == apiCenterWorkspace",
"group": "navigation@2"
},
{
"command": "azure-api-center.apiCenterWorkspace.refresh",
"when": "view == apiCenterWorkspace",
"group": "navigation@1"
},
{
"command": "azure-api-center.apiCenterWorkspace.collapse",
"when": "view == apiCenterWorkspace",
"group": "navigation@3"
}
],
"view/item/context": [
Expand All @@ -201,15 +245,15 @@
},
{
"command": "azure-api-center.open-api-docs",
"when": "view == apiCenterTreeView && viewItem == azureApiCenterApiVersionDefinitionTreeItem-openapi"
"when": "(view == apiCenterTreeView && viewItem == azureApiCenterApiVersionDefinitionTreeItem-openapi) || (view == apiCenterWorkspace && viewItem == azureApiCenterApiVersionDataPlaneDefinitionTreeItem-openapi)"
},
{
"command": "azure-api-center.open-postman",
"when": "view == apiCenterTreeView && viewItem =~ /never/"
},
{
"command": "azure-api-center.generate-api-client",
"when": "view == apiCenterTreeView && viewItem == azureApiCenterApiVersionDefinitionTreeItem-openapi"
"when": "(view == apiCenterTreeView && viewItem == azureApiCenterApiVersionDefinitionTreeItem-openapi) || (view == apiCenterWorkspace && viewItem == azureApiCenterApiVersionDataPlaneDefinitionTreeItem-openapi)"
},
{
"command": "azure-api-center.importOpenApiByFile",
Expand All @@ -221,7 +265,7 @@
},
{
"command": "azure-api-center.exportApi",
"when": "view == apiCenterTreeView && viewItem =~ /azureApiCenterApiVersionDefinitionTreeItem/"
"when": "(view == apiCenterTreeView && viewItem =~ /azureApiCenterApiVersionDefinitionTreeItem/) || (view == apiCenterWorkspace && viewItem =~ /azureApiCenterApiVersionDataPlaneDefinitionTreeItem/)"
},
{
"command": "azure-api-center.showOpenApi",
Expand All @@ -233,7 +277,7 @@
},
{
"command": "azure-api-center.generateMarkdownDocument",
"when": "view == apiCenterTreeView && viewItem == azureApiCenterApiVersionDefinitionTreeItem-openapi"
"when": "(view == apiCenterTreeView && viewItem == azureApiCenterApiVersionDefinitionTreeItem-openapi) || (view == apiCenterWorkspace && viewItem == azureApiCenterApiVersionDataPlaneDefinitionTreeItem-openapi)"
},
{
"command": "azure-api-center.registerApi",
Expand Down Expand Up @@ -277,6 +321,11 @@
"command": "azure-api-center.deleteCustomFunction",
"when": "view == apiCenterTreeView && viewItem == azureApiCenterFunction",
"group": "function@1"
},
{
"command": "azure-api-center.apiCenterWorkspace.removeApi",
"when": "view == apiCenterWorkspace && viewItem == azureApiCenterDataPlane",
"group": "inline@0"
}
],
"copilot": [
Expand Down Expand Up @@ -358,6 +407,14 @@
{
"command": "azure-api-center.deleteCustomFunction",
"when": "never"
},
{
"command": "azure-api-center.apiCenterWorkspace.removeApi",
"when": "never"
},
{
"command": "azure-api-center.apiCenterWorkspace.collapse",
"when": "never"
}
]
},
Expand All @@ -384,6 +441,7 @@
],
"configuration": [
{
"title": "Azure-Api-Center",
wenytang-ms marked this conversation as resolved.
Show resolved Hide resolved
"properties": {
"azure-api-center.selectedSubscriptions": {
"type": "array",
Expand Down
7 changes: 6 additions & 1 deletion package.nls.json
wenytang-ms marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
"azure-api-center.commands.deleteCustomFunction.title": "Delete",
"azure-api-center.chatParticipants.apicenter.description": "Build, discover, and consume great APIs.",
"azure-api-center.chatParticipants.apicenter.commands.list.description": "List available APIs.",
"azure-api-center.chatParticipants.apicenter.commands.find.description": "Find an API given a search query."
"azure-api-center.chatParticipants.apicenter.commands.find.description": "Find an API given a search query.",
"azure-api-center.commands.apiCenterWorkspace.collapse.title": "Collapse",
"azure-api-center.views.api-center-treeview.controlplane.title": "Azure API Center",
"azure-api-center.views.api-center-treeview.dataplane.title": "API Center Data View",
"azure-api-center.commands.apiCenterWorkspace.addApis.title": "Connect to an API Center",
"azure-api-center.commands.apiCenterWorkspace.removeApis.title": "Remove API Center"
}
58 changes: 58 additions & 0 deletions src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { RequestPrepareOptions, ServiceClient } from "@azure/ms-rest-js";
import { ISubscriptionContext } from "@microsoft/vscode-azext-utils";
import { ApiCenterApiVersionDefinitionExport, DataPlaneApiCenterApi, DataPlaneApiCenterApiVersion, DataPlaneApiCenterApiVersionDefinition } from "../ApiCenter/contracts";
import { APICenterDataPlaneRestAPIs } from "./ApiCenterRestAPIs";
export interface DataPlaneAccount {
readonly domain: string;
readonly tenantId: string;
readonly clientId: string;
}
export class ApiCenterDataPlaneService {
private susbcriptionContext: ISubscriptionContext;
constructor(susbcriptionContext: ISubscriptionContext) {
this.susbcriptionContext = susbcriptionContext;

Check warning on line 15 in src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts

View check run for this annotation

Codecov / codecov/patch

src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts#L15

Added line #L15 was not covered by tests
};
public async getApiCenterApis(): Promise<{ value: DataPlaneApiCenterApi[]; nextLink: string }> {
const client = new ServiceClient(this.susbcriptionContext.credentials);
let url = APICenterDataPlaneRestAPIs.ListApis(this.susbcriptionContext.subscriptionPath);
const options: RequestPrepareOptions = {
method: "GET",
url: url,
};
const response = await client.sendRequest(options);
return response.parsedBody;

Check warning on line 25 in src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts

View check run for this annotation

Codecov / codecov/patch

src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts#L18-L25

Added lines #L18 - L25 were not covered by tests
};
public async getAPiCenterApiVersions(apiName: string): Promise<{ value: DataPlaneApiCenterApiVersion[]; nextLink: string }> {
const client = new ServiceClient(this.susbcriptionContext.credentials);
let url = APICenterDataPlaneRestAPIs.ListApiVersions(this.susbcriptionContext.subscriptionPath, apiName);
const options: RequestPrepareOptions = {
method: "GET",
url: url,
};
const response = await client.sendRequest(options);
return response.parsedBody;

Check warning on line 35 in src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts

View check run for this annotation

Codecov / codecov/patch

src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts#L28-L35

Added lines #L28 - L35 were not covered by tests
};
public async getApiCenterApiDefinitions(apiName: string, apiVersion: string): Promise<{ value: DataPlaneApiCenterApiVersionDefinition[]; nextLink: string }> {
const client = new ServiceClient(this.susbcriptionContext.credentials);
let url = APICenterDataPlaneRestAPIs.ListApiDefinitions(this.susbcriptionContext.subscriptionPath, apiName, apiVersion);
const options: RequestPrepareOptions = {
method: "GET",
url: url,
};
const response = await client.sendRequest(options);
return response.parsedBody;

Check warning on line 45 in src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts

View check run for this annotation

Codecov / codecov/patch

src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts#L38-L45

Added lines #L38 - L45 were not covered by tests
};
public async exportSpecification(apiName: string,
apiVersionName: string,
apiCenterApiVersionDefinitionName: string): Promise<ApiCenterApiVersionDefinitionExport> {
const client = new ServiceClient(this.susbcriptionContext.credentials);
const options: RequestPrepareOptions = {
method: "POST",
url: APICenterDataPlaneRestAPIs.ExportApiDefinitions(this.susbcriptionContext.subscriptionPath, apiName, apiVersionName, apiCenterApiVersionDefinitionName),
};
const response = await client.sendRequest(options);
return response.parsedBody;
}

Check warning on line 57 in src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts

View check run for this annotation

Codecov / codecov/patch

src/azure/ApiCenter/ApiCenterDataPlaneAPIs.ts#L48-L57

Added lines #L48 - L57 were not covered by tests
}
10 changes: 10 additions & 0 deletions src/azure/ApiCenter/ApiCenterRestAPIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ export const APICenterRestAPIs = {
ImportRuleset: (subscriptionId: string, resourceGroupName: string, apiCenterName: string, restApiVersion: string) => `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.ApiCenter/services/${apiCenterName}/workspaces/default/staticAnalyzers/spectral/importRuleset?api-version=${restApiVersion}`,
ExportRuleset: (subscriptionId: string, resourceGroupName: string, apiCenterName: string, restApiVersion: string) => `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.ApiCenter/services/${apiCenterName}/workspaces/default/staticAnalyzers/spectral/exportRuleset?api-version=${restApiVersion}`,
};

export const APICenterDataPlaneRestAPIs = {
GetApi: (domain: string, apiName: string) => `https://${domain}/workspaces/default/apis/${apiName}`,
ListApis: (domain: string) => `https://${domain}/workspaces/default/apis`,
ListAllApis: (domain: string) => `https://${domain}/apis`,
GetApiVersion: (domain: string, apiName: string, versionName: string) => `https://${domain}/workspaces/default/apis/${apiName}/versions/${versionName}`,
ListApiVersions: (domain: string, apiName: string) => `https://${domain}/workspaces/default/apis/${apiName}/versions`,
ListApiDefinitions: (domain: string, apiName: string, apiVersion: string) => `https://${domain}/workspaces/default/apis/${apiName}/versions/${apiVersion}/definitions`,
ExportApiDefinitions: (domain: string, apiName: string, apiVersion: string, definitionName: string) => `https://${domain}/workspaces/default/apis/${apiName}/versions/${apiVersion}/definitions/${definitionName}:exportSpecification`,
};
33 changes: 33 additions & 0 deletions src/azure/ApiCenter/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export type GeneralApiCenter = ApiCenter | DataPlaneApiCenter;

export type ApiCenter = {
id: string;
Expand All @@ -12,6 +13,11 @@ export type ApiCenter = {
type: string;
};

export type DataPlaneApiCenter = {
name: string;
};

export type GeneralApiCenterApi = ApiCenterApi | DataPlaneApiCenterApi;

export type ApiCenterApi = {
id: string;
Expand All @@ -25,6 +31,16 @@ export type ApiCenterApi = {
type: string;
};

export type DataPlaneApiCenterApi = {
name: string;
title: string;
kind: string;
lifecycleStage: string;
externalDocumentation: [];
contacts: [];
customProperties: {};
};

export type ApiCenterEnvironment = {
id: string;
location: string;
Expand All @@ -35,6 +51,8 @@ export type ApiCenterEnvironment = {
type: string;
};

export type GeneralApiCenterApiVersion = ApiCenterApiVersion | DataPlaneApiCenterApiVersion;

export type ApiCenterApiVersion = {
id: string;
location: string;
Expand All @@ -47,6 +65,12 @@ export type ApiCenterApiVersion = {
type: string;
};

export type DataPlaneApiCenterApiVersion = {
name: string;
title: string;
lifecycleStage: string;
};

export type ApiCenterApiDeployment = {
id: string;
location: string;
Expand All @@ -57,6 +81,8 @@ export type ApiCenterApiDeployment = {
type: string;
};

export type GeneralApiCenterApiVersionDefinition = ApiCenterApiVersionDefinition | DataPlaneApiCenterApiVersionDefinition;

export type ApiCenterApiVersionDefinition = {
id: string;
location: string;
Expand All @@ -76,6 +102,13 @@ export type ApiCenterRulesetConfig = {
properties: {
};
};
export type DataPlaneApiCenterApiVersionDefinition = {
name: string;
title: string;
specification: {
name: string;
}
};

export type ApiCenterApiVersionDefinitionImport = {
format: string;
Expand Down
Loading
Loading