Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

feat: add universe support to googleapis libraries#548

Merged
alexander-fenster merged 1 commit intomainfrom
tpc
Mar 21, 2024
Merged

feat: add universe support to googleapis libraries#548
alexander-fenster merged 1 commit intomainfrom
tpc

Conversation

@alexander-fenster
Copy link
Copy Markdown
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.

@product-auto-label product-auto-label Bot added the size: l Pull request size is large. label Mar 21, 2024
Comment thread src/apirequest.ts
// Parse urls
if (options.url) {
options.url = urlTemplate.parse(options.url).expand(params);
let url = options.url;
Copy link
Copy Markdown
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.

Comment thread package.json
"karma-remap-coverage": "^0.1.5",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.0",
"karma-webpack": "^4.0.0",
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/api.ts
*/
export interface GlobalOptions extends MethodOptions {
auth?: GoogleAuth | OAuth2Client | BaseExternalAccountClient | string;
universeDomain?: string;
Copy link
Copy Markdown
Member

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants