@google-cloud/spanner
Advanced tools
Comparing version 6.5.0 to 6.6.0
@@ -144,2 +144,5 @@ "use strict"; | ||
: new session_pool_1.SessionPool(this, poolOptions); | ||
if (typeof poolOptions === 'object') { | ||
this.databaseRole = poolOptions.databaseRole || null; | ||
} | ||
this.formattedName_ = formattedName_; | ||
@@ -174,5 +177,6 @@ this.instance = instance; | ||
const labels = options.labels || {}; | ||
const databaseRole = options.databaseRole || this.databaseRole || null; | ||
const reqOpts = { | ||
database: this.formattedName_, | ||
sessionTemplate: { labels }, | ||
sessionTemplate: { labels: labels, creatorRole: databaseRole }, | ||
sessionCount: count, | ||
@@ -270,5 +274,8 @@ }; | ||
}; | ||
reqOpts.session = {}; | ||
if (options.labels) { | ||
reqOpts.session = { labels: options.labels }; | ||
reqOpts.session.labels = options.labels; | ||
} | ||
reqOpts.session.creatorRole = | ||
options.databaseRole || this.databaseRole || null; | ||
this.request({ | ||
@@ -431,2 +438,21 @@ client: 'SpannerClient', | ||
} | ||
getIamPolicy(optionsOrCallback, cb) { | ||
const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; | ||
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb; | ||
const reqOpts = { | ||
resource: this.formattedName_, | ||
options: { | ||
requestedPolicyVersion: options.requestedPolicyVersion || null, | ||
}, | ||
}; | ||
this.request({ | ||
client: 'DatabaseAdminClient', | ||
method: 'getIamPolicy', | ||
reqOpts, | ||
gaxOpts: options.gaxOptions, | ||
headers: this.resourceHeader_, | ||
}, (err, resp) => { | ||
callback(err, resp); | ||
}); | ||
} | ||
getSessions(optionsOrCallback, cb) { | ||
@@ -593,2 +619,31 @@ // eslint-disable-next-line @typescript-eslint/no-this-alias | ||
} | ||
getDatabaseRoles(optionsOrCallback, cb) { | ||
const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; | ||
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb; | ||
let reqOpts = { | ||
parent: this.formattedName_, | ||
}; | ||
// Copy over pageSize and pageToken values from gaxOptions. | ||
// However, values set on options take precedence. | ||
if (gaxOpts) { | ||
reqOpts = extend({}, { | ||
pageSize: gaxOpts.pageSize, | ||
pageToken: gaxOpts.pageToken, | ||
}, reqOpts); | ||
delete gaxOpts.pageSize; | ||
delete gaxOpts.pageToken; | ||
} | ||
this.request({ | ||
client: 'DatabaseAdminClient', | ||
method: 'listDatabaseRoles', | ||
reqOpts, | ||
gaxOpts, | ||
headers: this.resourceHeader_, | ||
}, (err, roles, nextPageRequest, ...args) => { | ||
const nextQuery = nextPageRequest | ||
? extend({}, gaxOpts, nextPageRequest) | ||
: null; | ||
callback(err, roles, nextQuery, ...args); | ||
}); | ||
} | ||
makePooledRequest_(config, callback) { | ||
@@ -1053,21 +1108,23 @@ const pool = this.pool_; | ||
} | ||
/** | ||
* Get a reference to a Table object. | ||
* | ||
* @throws {GoogleError} If a name is not provided. | ||
* | ||
* @param {string} name The name of the table. | ||
* @return {Table} A Table object. | ||
* | ||
* @example | ||
* ``` | ||
* const {Spanner} = require('@google-cloud/spanner'); | ||
* const spanner = new Spanner(); | ||
* | ||
* const instance = spanner.instance('my-instance'); | ||
* const database = instance.database('my-database'); | ||
* | ||
* const table = database.table('Singers'); | ||
* ``` | ||
*/ | ||
setIamPolicy(policy, optionsOrCallback, cb) { | ||
const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; | ||
const callback = typeof optionsOrCallback === 'function' | ||
? optionsOrCallback | ||
: cb; | ||
const gaxOpts = options; | ||
const reqOpts = { | ||
resource: this.formattedName_, | ||
policy: policy.policy, | ||
updateMask: policy.updateMask || null, | ||
}; | ||
this.request({ | ||
client: 'DatabaseAdminClient', | ||
method: 'setIamPolicy', | ||
reqOpts, | ||
gaxOpts: gaxOpts, | ||
headers: this.resourceHeader_, | ||
}, (err, resp) => { | ||
callback(err, resp); | ||
}); | ||
} | ||
table(name) { | ||
@@ -1164,2 +1221,3 @@ if (!name) { | ||
'getTransaction', | ||
'getIamPolicy', | ||
'restore', | ||
@@ -1166,0 +1224,0 @@ 'run', |
@@ -21,3 +21,3 @@ /*! | ||
import { common as p } from 'protobufjs'; | ||
import { Float, Int, Numeric, PGNumeric, PGJsonb, Struct } from './codec'; | ||
import { Float, Int, Numeric, PGNumeric, PGJsonb, SpannerDate, Struct } from './codec'; | ||
import { Backup } from './backup'; | ||
@@ -1074,1 +1074,2 @@ import { Database } from './database'; | ||
export default _default; | ||
export { Float, Int, Struct, Numeric, PGNumeric, SpannerDate }; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0; | ||
exports.SpannerDate = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0; | ||
const service_1 = require("./common-grpc/service"); | ||
@@ -30,2 +30,8 @@ const precise_date_1 = require("@google-cloud/precise-date"); | ||
const codec_1 = require("./codec"); | ||
Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return codec_1.Float; } }); | ||
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return codec_1.Int; } }); | ||
Object.defineProperty(exports, "Numeric", { enumerable: true, get: function () { return codec_1.Numeric; } }); | ||
Object.defineProperty(exports, "PGNumeric", { enumerable: true, get: function () { return codec_1.PGNumeric; } }); | ||
Object.defineProperty(exports, "SpannerDate", { enumerable: true, get: function () { return codec_1.SpannerDate; } }); | ||
Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return codec_1.Struct; } }); | ||
const backup_1 = require("./backup"); | ||
@@ -32,0 +38,0 @@ Object.defineProperty(exports, "Backup", { enumerable: true, get: function () { return backup_1.Backup; } }); |
@@ -152,2 +152,3 @@ /*! | ||
incStep?: number; | ||
databaseRole?: string | null; | ||
} | ||
@@ -154,0 +155,0 @@ /** |
@@ -35,2 +35,3 @@ "use strict"; | ||
incStep: 25, | ||
databaseRole: null, | ||
}; | ||
@@ -249,2 +250,5 @@ /** | ||
this.options.min = Math.min(this.options.min, this.options.max); | ||
this.options.databaseRole = this.options.databaseRole | ||
? this.options.databaseRole | ||
: database.databaseRole; | ||
this._inventory = { | ||
@@ -463,2 +467,3 @@ sessions: [], | ||
const labels = this.options.labels; | ||
const databaseRole = this.options.databaseRole; | ||
if (amount <= 0) { | ||
@@ -475,3 +480,4 @@ return; | ||
count: amount, | ||
labels, | ||
labels: labels, | ||
databaseRole: databaseRole, | ||
}); | ||
@@ -478,0 +484,0 @@ amount -= sessions.length; |
@@ -35,4 +35,12 @@ /*! | ||
} | ||
export type GetSessionMetadataCallback = NormalCallback<google.spanner.v1.ISession>; | ||
export type GetSessionMetadataResponse = [google.spanner.v1.ISession]; | ||
export interface GetSessionMetadataResponse { | ||
name?: string | null; | ||
labels?: { | ||
[k: string]: string; | ||
} | null; | ||
createTime?: google.protobuf.ITimestamp | null; | ||
approximateLastUseTime?: google.protobuf.ITimestamp | null; | ||
databaseRole?: string | null; | ||
} | ||
export type GetSessionMetadataCallback = NormalCallback<GetSessionMetadataResponse>; | ||
export type KeepAliveCallback = NormalCallback<google.spanner.v1.IResultSet>; | ||
@@ -39,0 +47,0 @@ export type KeepAliveResponse = [google.spanner.v1.IResultSet]; |
@@ -188,2 +188,5 @@ "use strict"; | ||
: callback; | ||
this.labels = options.labels || null; | ||
this.databaseRole = | ||
options.databaseRole || database.databaseRole || null; | ||
return database.createSession(options, (err, session, apiResponse) => { | ||
@@ -236,2 +239,4 @@ if (err) { | ||
if (resp) { | ||
resp.databaseRole = resp.creatorRole; | ||
delete resp.creatorRole; | ||
this.metadata = resp; | ||
@@ -238,0 +243,0 @@ } |
{ | ||
"name": "@google-cloud/spanner", | ||
"description": "Cloud Spanner Client Library for Node.js", | ||
"version": "6.5.0", | ||
"version": "6.6.0", | ||
"license": "Apache-2.0", | ||
@@ -94,3 +94,3 @@ "author": "Google Inc.", | ||
"@types/through2": "^2.0.34", | ||
"@types/uuid": "^8.0.0", | ||
"@types/uuid": "^9.0.0", | ||
"binary-search-bounds": "^2.0.4", | ||
@@ -97,0 +97,0 @@ "c8": "^7.0.0", |
@@ -92,2 +92,3 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
| --------------------------- | --------------------------------- | ------ | | ||
| Add and drop new database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/add-and-drop-new-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/add-and-drop-new-database-role.js,samples/README.md) | | ||
| Backups-cancel | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-cancel.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-cancel.js,samples/README.md) | | ||
@@ -115,3 +116,5 @@ | Copies a source backup | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-copy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-copy.js,samples/README.md) | | ||
| DML | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/dml.js,samples/README.md) | | ||
| Enable fine grained access control | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/enable-fine-grained-access.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/enable-fine-grained-access.js,samples/README.md) | | ||
| Get-commit-stats | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-commit-stats.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-commit-stats.js,samples/README.md) | | ||
| List database roles | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-database-roles.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-database-roles.js,samples/README.md) | | ||
| Gets the instance config metadata for the configuration nam6 | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-instance-config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-instance-config.js,samples/README.md) | | ||
@@ -158,2 +161,3 @@ | Creates a new value-storing index | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/index-create-storing.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/index-create-storing.js,samples/README.md) | | ||
| Quickstart | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | | ||
| Read data with database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-data-with-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-data-with-database-role.js,samples/README.md) | | ||
| Sets a request tag for a single query | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/request-tag.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/request-tag.js,samples/README.md) | | ||
@@ -160,0 +164,0 @@ | Run Batch update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-batch-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-batch-dml.js,samples/README.md) | |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
6128148
102249
242