Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
fix(browser): check for fetch on window (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored Nov 23, 2020
1 parent 2329129 commit 3c28ff7
Show file tree
Hide file tree
Showing 6 changed files with 967 additions and 222 deletions.
831 changes: 773 additions & 58 deletions protos/protos.json

Large diffs are not rendered by default.

100 changes: 54 additions & 46 deletions src/v1beta/game_server_clusters_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

/* global window */
import * as gax from 'google-gax';
import {
Callback,
Expand All @@ -31,6 +32,11 @@ import * as path from 'path';
import {Transform} from 'stream';
import {RequestType} from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
/**
* Client JSON configuration object, loaded from
* `src/v1beta/game_server_clusters_service_client_config.json`.
* This file defines retry strategy and timeouts for all API methods in this library.
*/
import * as gapicConfig from './game_server_clusters_service_client_config.json';
import {operationsProtos} from 'google-gax';
const version = require('../../../package.json').version;
Expand Down Expand Up @@ -86,9 +92,9 @@ export class GameServerClustersServiceClient {
* your project ID will be detected automatically.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - client configuration override.
* TODO(@alexander-fenster): link to gax documentation.
* @param {boolean} fallback - Use HTTP fallback mode.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
Expand All @@ -102,7 +108,9 @@ export class GameServerClustersServiceClient {
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
const port = opts?.port || staticMembers.port;
const clientConfig = opts?.clientConfig ?? {};
const fallback = opts?.fallback ?? typeof window !== 'undefined';
const fallback =
opts?.fallback ??
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
opts = Object.assign({servicePath, port, clientConfig, fallback}, opts);

// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
Expand Down Expand Up @@ -396,7 +404,7 @@ export class GameServerClustersServiceClient {
// -------------------
getGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IGetGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
protos.google.cloud.gaming.v1beta.IGameServerCluster,
Expand All @@ -409,7 +417,7 @@ export class GameServerClustersServiceClient {
>;
getGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IGetGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
protos.google.cloud.gaming.v1beta.IGameServerCluster,
| protos.google.cloud.gaming.v1beta.IGetGameServerClusterRequest
Expand Down Expand Up @@ -450,7 +458,7 @@ export class GameServerClustersServiceClient {
getGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IGetGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
protos.google.cloud.gaming.v1beta.IGameServerCluster,
| protos.google.cloud.gaming.v1beta.IGetGameServerClusterRequest
Expand All @@ -476,12 +484,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand All @@ -496,7 +504,7 @@ export class GameServerClustersServiceClient {
}
previewCreateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterResponse,
Expand All @@ -509,7 +517,7 @@ export class GameServerClustersServiceClient {
>;
previewCreateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterResponse,
| protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterRequest
Expand Down Expand Up @@ -556,7 +564,7 @@ export class GameServerClustersServiceClient {
previewCreateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterResponse,
| protos.google.cloud.gaming.v1beta.IPreviewCreateGameServerClusterRequest
Expand All @@ -582,12 +590,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand All @@ -606,7 +614,7 @@ export class GameServerClustersServiceClient {
}
previewDeleteGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterResponse,
Expand All @@ -619,7 +627,7 @@ export class GameServerClustersServiceClient {
>;
previewDeleteGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterResponse,
| protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterRequest
Expand Down Expand Up @@ -661,7 +669,7 @@ export class GameServerClustersServiceClient {
previewDeleteGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterResponse,
| protos.google.cloud.gaming.v1beta.IPreviewDeleteGameServerClusterRequest
Expand All @@ -687,12 +695,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand All @@ -711,7 +719,7 @@ export class GameServerClustersServiceClient {
}
previewUpdateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterResponse,
Expand All @@ -724,7 +732,7 @@ export class GameServerClustersServiceClient {
>;
previewUpdateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterResponse,
| protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterRequest
Expand Down Expand Up @@ -773,7 +781,7 @@ export class GameServerClustersServiceClient {
previewUpdateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterResponse,
| protos.google.cloud.gaming.v1beta.IPreviewUpdateGameServerClusterRequest
Expand All @@ -799,12 +807,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand All @@ -824,7 +832,7 @@ export class GameServerClustersServiceClient {

createGameServerCluster(
request: protos.google.cloud.gaming.v1beta.ICreateGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
LROperation<
Expand All @@ -837,7 +845,7 @@ export class GameServerClustersServiceClient {
>;
createGameServerCluster(
request: protos.google.cloud.gaming.v1beta.ICreateGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
LROperation<
protos.google.cloud.gaming.v1beta.IGameServerCluster,
Expand Down Expand Up @@ -886,7 +894,7 @@ export class GameServerClustersServiceClient {
createGameServerCluster(
request: protos.google.cloud.gaming.v1beta.ICreateGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
LROperation<
protos.google.cloud.gaming.v1beta.IGameServerCluster,
Expand Down Expand Up @@ -914,12 +922,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand Down Expand Up @@ -975,7 +983,7 @@ export class GameServerClustersServiceClient {
}
deleteGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IDeleteGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
LROperation<
Expand All @@ -988,7 +996,7 @@ export class GameServerClustersServiceClient {
>;
deleteGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IDeleteGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
LROperation<
protos.google.protobuf.IEmpty,
Expand Down Expand Up @@ -1033,7 +1041,7 @@ export class GameServerClustersServiceClient {
deleteGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IDeleteGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
LROperation<
protos.google.protobuf.IEmpty,
Expand Down Expand Up @@ -1061,12 +1069,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand Down Expand Up @@ -1122,7 +1130,7 @@ export class GameServerClustersServiceClient {
}
updateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IUpdateGameServerClusterRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
LROperation<
Expand All @@ -1135,7 +1143,7 @@ export class GameServerClustersServiceClient {
>;
updateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IUpdateGameServerClusterRequest,
options: gax.CallOptions,
options: CallOptions,
callback: Callback<
LROperation<
protos.google.cloud.gaming.v1beta.IGameServerCluster,
Expand Down Expand Up @@ -1187,7 +1195,7 @@ export class GameServerClustersServiceClient {
updateGameServerCluster(
request: protos.google.cloud.gaming.v1beta.IUpdateGameServerClusterRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| Callback<
LROperation<
protos.google.cloud.gaming.v1beta.IGameServerCluster,
Expand Down Expand Up @@ -1215,12 +1223,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand Down Expand Up @@ -1276,7 +1284,7 @@ export class GameServerClustersServiceClient {
}
listGameServerClusters(
request: protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
options?: gax.CallOptions
options?: CallOptions
): Promise<
[
protos.google.cloud.gaming.v1beta.IGameServerCluster[],
Expand All @@ -1286,7 +1294,7 @@ export class GameServerClustersServiceClient {
>;
listGameServerClusters(
request: protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
options: gax.CallOptions,
options: CallOptions,
callback: PaginationCallback<
protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
| protos.google.cloud.gaming.v1beta.IListGameServerClustersResponse
Expand Down Expand Up @@ -1342,7 +1350,7 @@ export class GameServerClustersServiceClient {
listGameServerClusters(
request: protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
optionsOrCallback?:
| gax.CallOptions
| CallOptions
| PaginationCallback<
protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
| protos.google.cloud.gaming.v1beta.IListGameServerClustersResponse
Expand All @@ -1365,12 +1373,12 @@ export class GameServerClustersServiceClient {
]
> | void {
request = request || {};
let options: gax.CallOptions;
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand Down Expand Up @@ -1422,7 +1430,7 @@ export class GameServerClustersServiceClient {
*/
listGameServerClustersStream(
request?: protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
options?: gax.CallOptions
options?: CallOptions
): Transform {
request = request || {};
options = options || {};
Expand Down Expand Up @@ -1482,7 +1490,7 @@ export class GameServerClustersServiceClient {
*/
listGameServerClustersAsync(
request?: protos.google.cloud.gaming.v1beta.IListGameServerClustersRequest,
options?: gax.CallOptions
options?: CallOptions
): AsyncIterable<protos.google.cloud.gaming.v1beta.IGameServerCluster> {
request = request || {};
options = options || {};
Expand Down
Loading

0 comments on commit 3c28ff7

Please sign in to comment.