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

Added endpoints for sovereign clouds for PPAPI service #1069

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
"Hi! Power Pages lets you build secure, professional websites that you can quickly configure and publish across web browsers and devices.\n\nTo create your website, visit the [Power Pages](https://powerpages.microsoft.com/).\nReturn to this chat and @powerpages can help you write and edit your website code.": "Hi! Power Pages lets you build secure, professional websites that you can quickly configure and publish across web browsers and devices.\n\nTo create your website, visit the [Power Pages](https://powerpages.microsoft.com/).\nReturn to this chat and @powerpages can help you write and edit your website code.",
"Checking for active auth profile...": "Checking for active auth profile...",
"@PowerPages is not yet available in your region.": "@PowerPages is not yet available in your region.",
"Failed to get site content from NL2Site service": "Failed to get site content from NL2Site service",
"Generating webpages...": "Generating webpages...",
"Generating a new Power Pages site...": "Generating a new Power Pages site...",
"Failed to create a new Power Pages site. Please try again.": "Failed to create a new Power Pages site. Please try again.",
"Select Folder for new PCF Control/Do not translate 'PCF' as it is a product name.": {
"message": "Select Folder for new PCF Control",
"comment": [
Expand Down
6 changes: 3 additions & 3 deletions loc/translations-export/vscode-powerplatform.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ The {3} represents Solution's Type (Managed or Unmanaged), but that test is loca
<trans-unit id="++CODE++f9e17ed11037dab93f8820c30db63b2ff2a045b5761f71818b7291afae60f199">
<source xml:lang="en">Explain the following code {% include 'Page Copy'%}</source>
</trans-unit>
<trans-unit id="++CODE++b985f1515c42b4b5b0c11a3d7b3286fc9d66997d476668ab1f93a4a11499fef5">
<source xml:lang="en">Failed to create a new Power Pages site. Please try again.</source>
</trans-unit>
<trans-unit id="++CODE++2310c6b7e5953cab877859ba1fcfa98e58e1508677df9412010e9b578ea237f4">
<source xml:lang="en">Failed to create: {0}.</source>
<note>{0} will be replaced by the error message.</note>
Expand All @@ -159,9 +162,6 @@ The {3} represents Solution's Type (Managed or Unmanaged), but that test is loca
<trans-unit id="++CODE++862d6197d64601aa13ce30db5ec5b8f819ad00fe21e3b031a3e47fe22ef68fb3">
<source xml:lang="en">Failed to get file ready for edit: {0}</source>
</trans-unit>
<trans-unit id="++CODE++41405814c44fb391a3f8e31d1a3bc20299cd2e87979ebfbd1eb9488be12c617a">
<source xml:lang="en">Failed to get site content from NL2Site service</source>
</trans-unit>
<trans-unit id="++CODE++a9e36b880dd45b64ae5601865540605296febf9bd855fc46d9c35c2c2ed9a7f2">
<source xml:lang="en">Feature is not enabled for this geo.</source>
</trans-unit>
Expand Down
15 changes: 13 additions & 2 deletions src/common/services/AuthenticationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ import {
VSCODE_EXTENSION_PPAPI_WEBSITES_AUTHENTICATION_FAILED
} from "./TelemetryConstants";
import { ERROR_CONSTANTS } from "../ErrorConstants";
import { BAP_SERVICE_SCOPE_DEFAULT, INTELLIGENCE_SCOPE_DEFAULT, PPAPI_PREPROD_WEBSITES_SERVICE_SCOPE_DEFAULT, PPAPI_WEBSITES_SERVICE_SCOPE_DEFAULT, PROVIDER_ID, SCOPE_OPTION_CONTACTS_READ, SCOPE_OPTION_DEFAULT, SCOPE_OPTION_OFFLINE_ACCESS, SCOPE_OPTION_USERS_READ_BASIC_ALL, ServiceEndpointCategory } from "./Constants";
import { BAP_SERVICE_SCOPE_DEFAULT, INTELLIGENCE_SCOPE_DEFAULT, PPAPI_GCC_HIGH_DOD_WEBSITES_SERVICE_SCOPE_DEFAULT, PPAPI_MOONCAKE_WEBSITES_SERVICE_SCOPE_DEFAULT, PPAPI_PREPROD_WEBSITES_SERVICE_SCOPE_DEFAULT, PPAPI_TEST_WEBSITES_SERVICE_SCOPE_DEFAULT, PPAPI_WEBSITES_SERVICE_SCOPE_DEFAULT, PROVIDER_ID, SCOPE_OPTION_CONTACTS_READ, SCOPE_OPTION_DEFAULT, SCOPE_OPTION_OFFLINE_ACCESS, SCOPE_OPTION_USERS_READ_BASIC_ALL, ServiceEndpointCategory } from "./Constants";
import jwt_decode from 'jwt-decode';
import { showErrorDialog } from "../utilities/errorHandlerUtil";

const serviceScopeMapping: { [key in ServiceEndpointCategory]: string } = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we also logging this info in the Preview flow? It will help in debugging if a call fails for a particular region

[ServiceEndpointCategory.NONE]: "",
[ServiceEndpointCategory.PROD]: PPAPI_WEBSITES_SERVICE_SCOPE_DEFAULT,
[ServiceEndpointCategory.PREPROD]: PPAPI_PREPROD_WEBSITES_SERVICE_SCOPE_DEFAULT,
[ServiceEndpointCategory.TEST]: PPAPI_TEST_WEBSITES_SERVICE_SCOPE_DEFAULT,
[ServiceEndpointCategory.MOONCAKE]: PPAPI_MOONCAKE_WEBSITES_SERVICE_SCOPE_DEFAULT,
[ServiceEndpointCategory.GCC]: PPAPI_GCC_HIGH_DOD_WEBSITES_SERVICE_SCOPE_DEFAULT,
[ServiceEndpointCategory.DOD]: PPAPI_GCC_HIGH_DOD_WEBSITES_SERVICE_SCOPE_DEFAULT,
[ServiceEndpointCategory.HIGH]: PPAPI_GCC_HIGH_DOD_WEBSITES_SERVICE_SCOPE_DEFAULT,
};

export function getCommonHeadersForDataverse(
accessToken: string,
useOctetStreamContentType?: boolean
Expand Down Expand Up @@ -300,7 +311,7 @@ export async function powerPlatformAPIAuthentication(
firstTimeAuth = false
): Promise<string> {
let accessToken = "";
const PPAPI_WEBSITES_ENDPOINT = [ServiceEndpointCategory.TEST, ServiceEndpointCategory.PREPROD].includes(serviceEndpointStamp) ? PPAPI_PREPROD_WEBSITES_SERVICE_SCOPE_DEFAULT : PPAPI_WEBSITES_SERVICE_SCOPE_DEFAULT;
const PPAPI_WEBSITES_ENDPOINT = serviceScopeMapping[serviceEndpointStamp];
try {
let session = await vscode.authentication.getSession(
PROVIDER_ID,
Expand Down
3 changes: 3 additions & 0 deletions src/common/services/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const BAP_ENVIRONMENT_LIST_URL = `scopes/admin/environments?api-version={
export const PPAPI_WEBSITES_API_VERSION = '2022-03-01-preview';
export const PPAPI_WEBSITES_SERVICE_SCOPE_DEFAULT = "https://api.powerplatform.com/.default";
export const PPAPI_PREPROD_WEBSITES_SERVICE_SCOPE_DEFAULT = "https://api.preprod.powerplatform.com/.default";
export const PPAPI_TEST_WEBSITES_SERVICE_SCOPE_DEFAULT = "https://api.test.powerplatform.com/.default";
export const PPAPI_MOONCAKE_WEBSITES_SERVICE_SCOPE_DEFAULT = "https://api.powerplatform.cn/.default";
export const PPAPI_GCC_HIGH_DOD_WEBSITES_SERVICE_SCOPE_DEFAULT = "https://api.powerplatform.us/.default";
export const PPAPI_WEBSITES_ENDPOINT = `{rootURL}/powerpages/environments/{environmentId}/websites`;

export enum ServiceEndpointCategory {
Expand Down
10 changes: 8 additions & 2 deletions src/common/services/PPAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ export class PPAPIService {
case ServiceEndpointCategory.PROD:
ppapiEndpoint = "https://api.powerplatform.com";
break;
// All below endpoints are not supported yet
case ServiceEndpointCategory.DOD:
ppapiEndpoint = "https://api.powerplatform.us";
break;
case ServiceEndpointCategory.GCC:
case ServiceEndpointCategory.HIGH:
ppapiEndpoint = "https://api.powerplatform.us";
break;
case ServiceEndpointCategory.MOONCAKE:
ppapiEndpoint = "https://api.powerplatform.cn";
break;
// Below endpoints are not supported yet
case ServiceEndpointCategory.HIGH:
default:
sendTelemetryEvent(telemetry, { eventName: VSCODE_EXTENSION_GET_PPAPI_WEBSITES_ENDPOINT_UNSUPPORTED_REGION, data: serviceEndpointStamp });
break;
Expand Down
Loading