diff --git a/packages/google-cloud-gkeconnect-gateway/.jsdoc.js b/packages/google-cloud-gkeconnect-gateway/.jsdoc.js index dac3006fadb..009c138bd99 100644 --- a/packages/google-cloud-gkeconnect-gateway/.jsdoc.js +++ b/packages/google-cloud-gkeconnect-gateway/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2024 Google LLC', + copyright: 'Copyright 2025 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/gke-connect-gateway', diff --git a/packages/google-cloud-gkeconnect-gateway/.mocharc.js b/packages/google-cloud-gkeconnect-gateway/.mocharc.js index 7e843ab5a75..eef6173ab44 100644 --- a/packages/google-cloud-gkeconnect-gateway/.mocharc.js +++ b/packages/google-cloud-gkeconnect-gateway/.mocharc.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/.prettierrc.js b/packages/google-cloud-gkeconnect-gateway/.prettierrc.js index 120c6aa3e6e..b189724933b 100644 --- a/packages/google-cloud-gkeconnect-gateway/.prettierrc.js +++ b/packages/google-cloud-gkeconnect-gateway/.prettierrc.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/README.md b/packages/google-cloud-gkeconnect-gateway/README.md index 7a0b98d15ce..4bbd12d37d1 100644 --- a/packages/google-cloud-gkeconnect-gateway/README.md +++ b/packages/google-cloud-gkeconnect-gateway/README.md @@ -44,7 +44,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. 1. [Select or create a Cloud Platform project][projects]. 1. [Enable billing for your project][billing]. 1. [Enable the GKE Connect Gateway API][enable_api]. -1. [Set up authentication with a service account][auth] so you can access the +1. [Set up authentication][auth] so you can access the API from your local workstation. ### Installing the client library @@ -150,4 +150,4 @@ See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [projects]: https://console.cloud.google.com/project [billing]: https://support.google.com/cloud/answer/6293499#enable-billing [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=connectgateway.googleapis.com -[auth]: https://cloud.google.com/docs/authentication/getting-started +[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local diff --git a/packages/google-cloud-gkeconnect-gateway/protos/protos.d.ts b/packages/google-cloud-gkeconnect-gateway/protos/protos.d.ts index 76c80bd714f..7546a107a27 100644 --- a/packages/google-cloud-gkeconnect-gateway/protos/protos.d.ts +++ b/packages/google-cloud-gkeconnect-gateway/protos/protos.d.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/protos/protos.js b/packages/google-cloud-gkeconnect-gateway/protos/protos.js index f72f654f6bc..03d2ede0f52 100644 --- a/packages/google-cloud-gkeconnect-gateway/protos/protos.js +++ b/packages/google-cloud-gkeconnect-gateway/protos/protos.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/protos/protos.json b/packages/google-cloud-gkeconnect-gateway/protos/protos.json index e5cc54242c4..857992fce85 100644 --- a/packages/google-cloud-gkeconnect-gateway/protos/protos.json +++ b/packages/google-cloud-gkeconnect-gateway/protos/protos.json @@ -1,4 +1,7 @@ { + "options": { + "syntax": "proto3" + }, "nested": { "google": { "nested": { diff --git a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1/gateway_control.generate_credentials.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1/gateway_control.generate_credentials.js index 5cd5b80a7f5..6dff1506e17 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1/gateway_control.generate_credentials.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1/gateway_control.generate_credentials.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_control.generate_credentials.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_control.generate_credentials.js index d4c5fbd5e97..4fb4efa3df9 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_control.generate_credentials.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_control.generate_credentials.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/src/index.ts b/packages/google-cloud-gkeconnect-gateway/src/index.ts index d56e850fea9..aa49dc0e5a1 100644 --- a/packages/google-cloud-gkeconnect-gateway/src/index.ts +++ b/packages/google-cloud-gkeconnect-gateway/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/src/v1/gateway_control_client.ts b/packages/google-cloud-gkeconnect-gateway/src/v1/gateway_control_client.ts index bf48e8d0ef2..35e6de9c107 100644 --- a/packages/google-cloud-gkeconnect-gateway/src/v1/gateway_control_client.ts +++ b/packages/google-cloud-gkeconnect-gateway/src/v1/gateway_control_client.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -133,6 +133,12 @@ export class GatewayControlClient { ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; + // Implicitly enable HTTP transport for the APIs that use REST as transport (e.g. Google Cloud Compute). + if (!opts) { + opts = {fallback: true}; + } else { + opts.fallback = opts.fallback ?? true; + } const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); diff --git a/packages/google-cloud-gkeconnect-gateway/src/v1/index.ts b/packages/google-cloud-gkeconnect-gateway/src/v1/index.ts index 58f2810e2db..dd818f3b743 100644 --- a/packages/google-cloud-gkeconnect-gateway/src/v1/index.ts +++ b/packages/google-cloud-gkeconnect-gateway/src/v1/index.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_control_client.ts b/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_control_client.ts index 8cc2910c798..27c4ad35923 100644 --- a/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_control_client.ts +++ b/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_control_client.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -133,6 +133,12 @@ export class GatewayControlClient { ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; + // Implicitly enable HTTP transport for the APIs that use REST as transport (e.g. Google Cloud Compute). + if (!opts) { + opts = {fallback: true}; + } else { + opts.fallback = opts.fallback ?? true; + } const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); diff --git a/packages/google-cloud-gkeconnect-gateway/src/v1beta1/index.ts b/packages/google-cloud-gkeconnect-gateway/src/v1beta1/index.ts index 58f2810e2db..dd818f3b743 100644 --- a/packages/google-cloud-gkeconnect-gateway/src/v1beta1/index.ts +++ b/packages/google-cloud-gkeconnect-gateway/src/v1beta1/index.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.js b/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.js index 78439a18c9e..8dc0c97ee46 100644 --- a/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.js @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.ts index 2801297f835..1fc62d81f20 100644 --- a/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-gkeconnect-gateway/system-test/fixtures/sample/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/system-test/install.ts b/packages/google-cloud-gkeconnect-gateway/system-test/install.ts index 83b83f332c3..d927b34361d 100644 --- a/packages/google-cloud-gkeconnect-gateway/system-test/install.ts +++ b/packages/google-cloud-gkeconnect-gateway/system-test/install.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1.ts b/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1.ts index 9f8661479ea..83c4adea94f 100644 --- a/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1.ts +++ b/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,10 +20,10 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import {describe, it, beforeEach, afterEach} from 'mocha'; import * as gatewaycontrolModule from '../src'; -import {protobuf} from 'google-gax'; +import {GoogleAuth, protobuf} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -65,6 +65,19 @@ function stubSimpleCallWithCallback( } describe('v1.GatewayControlClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon + .stub() + .resolves({Authorization: 'Bearer SOME_TOKEN'}), + }), + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); describe('Common methods', () => { it('has apiEndpoint', () => { const client = new gatewaycontrolModule.v1.GatewayControlClient(); @@ -179,7 +192,7 @@ describe('v1.GatewayControlClient', () => { it('has initialize method and supports deferred initialization', async () => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); assert.strictEqual(client.gatewayControlStub, undefined); @@ -189,7 +202,7 @@ describe('v1.GatewayControlClient', () => { it('has close method for the initialized client', done => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -201,7 +214,7 @@ describe('v1.GatewayControlClient', () => { it('has close method for the non-initialized client', done => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); assert.strictEqual(client.gatewayControlStub, undefined); @@ -213,7 +226,7 @@ describe('v1.GatewayControlClient', () => { it('has getProjectId method', async () => { const fakeProjectId = 'fake-project-id'; const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); @@ -225,7 +238,7 @@ describe('v1.GatewayControlClient', () => { it('has getProjectId method with callback', async () => { const fakeProjectId = 'fake-project-id'; const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.auth.getProjectId = sinon @@ -248,7 +261,7 @@ describe('v1.GatewayControlClient', () => { describe('generateCredentials', () => { it('invokes generateCredentials without error', async () => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -280,7 +293,7 @@ describe('v1.GatewayControlClient', () => { it('invokes generateCredentials without error using callback', async () => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -327,7 +340,7 @@ describe('v1.GatewayControlClient', () => { it('invokes generateCredentials with error', async () => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -358,7 +371,7 @@ describe('v1.GatewayControlClient', () => { it('invokes generateCredentials with closed client', async () => { const client = new gatewaycontrolModule.v1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); diff --git a/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1beta1.ts b/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1beta1.ts index 1d5b83fe506..c1c056a4792 100644 --- a/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1beta1.ts +++ b/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_control_v1beta1.ts @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,10 +20,10 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import {describe, it, beforeEach, afterEach} from 'mocha'; import * as gatewaycontrolModule from '../src'; -import {protobuf} from 'google-gax'; +import {GoogleAuth, protobuf} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -65,6 +65,19 @@ function stubSimpleCallWithCallback( } describe('v1beta1.GatewayControlClient', () => { + let googleAuth: GoogleAuth; + beforeEach(() => { + googleAuth = { + getClient: sinon.stub().resolves({ + getRequestHeaders: sinon + .stub() + .resolves({Authorization: 'Bearer SOME_TOKEN'}), + }), + } as unknown as GoogleAuth; + }); + afterEach(() => { + sinon.restore(); + }); describe('Common methods', () => { it('has apiEndpoint', () => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient(); @@ -180,7 +193,7 @@ describe('v1beta1.GatewayControlClient', () => { it('has initialize method and supports deferred initialization', async () => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); assert.strictEqual(client.gatewayControlStub, undefined); @@ -190,7 +203,7 @@ describe('v1beta1.GatewayControlClient', () => { it('has close method for the initialized client', done => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -202,7 +215,7 @@ describe('v1beta1.GatewayControlClient', () => { it('has close method for the non-initialized client', done => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); assert.strictEqual(client.gatewayControlStub, undefined); @@ -214,7 +227,7 @@ describe('v1beta1.GatewayControlClient', () => { it('has getProjectId method', async () => { const fakeProjectId = 'fake-project-id'; const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); @@ -226,7 +239,7 @@ describe('v1beta1.GatewayControlClient', () => { it('has getProjectId method with callback', async () => { const fakeProjectId = 'fake-project-id'; const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.auth.getProjectId = sinon @@ -249,7 +262,7 @@ describe('v1beta1.GatewayControlClient', () => { describe('generateCredentials', () => { it('invokes generateCredentials without error', async () => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -281,7 +294,7 @@ describe('v1beta1.GatewayControlClient', () => { it('invokes generateCredentials without error using callback', async () => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -328,7 +341,7 @@ describe('v1beta1.GatewayControlClient', () => { it('invokes generateCredentials with error', async () => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize(); @@ -359,7 +372,7 @@ describe('v1beta1.GatewayControlClient', () => { it('invokes generateCredentials with closed client', async () => { const client = new gatewaycontrolModule.v1beta1.GatewayControlClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, + auth: googleAuth, projectId: 'bogus', }); client.initialize();