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: add universe support to googleapis libraries #548

Merged
merged 1 commit into from
Mar 21, 2024
Merged

Conversation

alexander-fenster
Copy link
Contributor

Adding a global option universeDomain (can also be spelled as universe_domain). Example usage with google-api-nodejs-client (for Cloud KMS):

import * as cloudkms from '@googleapis/cloudkms';

const googleAuth = new auth.GoogleAuth({
  scopes: [
    'https://www.googleapis.com/auth/cloud-platform',
    'https://www.googleapis.com/auth/cloudkms',
  ],
});
const kms = cloudkms.cloudkms({
  auth: googleAuth,
  version: 'v1',
  universeDomain: 'example.com',  // use your Trusted Partner Cloud universe domain
});
const project = await googleAuth.getProjectId();
const location = 'some-existing-location-such-as-us-central1';
const result = await kms.projects.locations.keyRings.list({
  parent: `projects/${project}/locations/${location}`,
});
console.log(result.data);

The universe domain can be also configured with GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable.

Note that for services which have modern libraries published to @google-cloud/ NPM organization (e.g. @google-cloud/kms), we recommend using them and not @googleapis libraries. Still adding this feature to @googleapis for completeness.

@alexander-fenster alexander-fenster requested a review from a team as a code owner March 21, 2024 05:55
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Mar 21, 2024
@@ -160,7 +160,11 @@ async function createAPIRequestAsync<T>(parameters: APIRequestParams) {

// Parse urls
if (options.url) {
options.url = urlTemplate.parse(options.url).expand(params);
let url = options.url;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an unrelated fix: without this, the existing code does not compile on the new TypeScript version.

@@ -69,7 +69,7 @@
"karma-mocha": "^2.0.0",
"karma-remap-coverage": "^0.1.5",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.0",
"karma-webpack": "^4.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated, webpack and karma-webpack v5 require Node 18 and it breaks tests. These are dev dependencies, we don't really care.

@alexander-fenster alexander-fenster changed the title feat: support Trusted Partner Cloud feat: add universe support to googleapis libraries Mar 21, 2024
Copy link
Member

@viacheslav-rostovtsev viacheslav-rostovtsev left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -45,6 +45,8 @@ export interface APIRequestContext {
*/
export interface GlobalOptions extends MethodOptions {
auth?: GoogleAuth | OAuth2Client | BaseExternalAccountClient | string;
universeDomain?: string;

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants