The InstanceConfig class represents a possible configuration for a Cloud Spanner instance.
Create an InstanceConfig
object to interact with a Cloud Spanner instance config.
Inheritance
common_5.GrpcServiceObject > InstanceConfigPackage
@google-cloud/spannerExample
const {Spanner} = require('@google-cloud/spanner');
const spanner = new Spanner();
const instance = spanner.instanceConfig('my-instance-config');
Constructors
(constructor)(spanner, name)
constructor(spanner: Spanner, name: string);
Constructs a new instance of the InstanceConfig
class
Parameters | |
---|---|
Name | Description |
spanner |
Spanner
|
name |
string
|
Properties
formattedName_
formattedName_: string;
metadata
metadata?: IInstanceConfig;
request
request: InstanceConfigRequest;
resourceHeader_
resourceHeader_: {
[k: string]: string;
};
Methods
delete(config)
delete(config?: DeleteInstanceConfigRequest): Promise<DeleteInstanceConfigResponse>;
Delete the instance config. This function can only be called for deleting user managed instance configs.
Wrapper around .
Parameter | |
---|---|
Name | Description |
config |
DeleteInstanceConfigRequest
|
Returns | |
---|---|
Type | Description |
Promise<DeleteInstanceConfigResponse> | {Promise
|
const {Spanner} = require('@google-cloud/spanner');
const spanner = new Spanner();
const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
instanceConfig.delete(function(err, apiResponse) {
if (err) {
// Error handling omitted.
}
// Instance config was deleted successfully.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
instanceConfig.delete().then(function(data) {
const apiResponse = data[0];
});
delete(callback)
delete(callback: DeleteInstanceConfigCallback): void;
Parameter | |
---|---|
Name | Description |
callback |
DeleteInstanceConfigCallback
|
Returns | |
---|---|
Type | Description |
void |
delete(config, callback)
delete(config: DeleteInstanceConfigRequest, callback: DeleteInstanceConfigCallback): void;
Parameters | |
---|---|
Name | Description |
config |
DeleteInstanceConfigRequest
|
callback |
DeleteInstanceConfigCallback
|
Returns | |
---|---|
Type | Description |
void |
exists()
exists(): Promise<ExistsInstanceConfigResponse>;
Check if an instance config exists.
InstanceConfig#exists
Returns | |
---|---|
Type | Description |
Promise<ExistsInstanceConfigResponse> | {Promise
|
const {Spanner} = require('@google-cloud/spanner');
const spanner = new Spanner();
const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
const exists = await instanceConfig.exists();
console.log(`Does instance config exist? ${exists}`);
exists(callback)
exists(callback: ExistsInstanceConfigCallback): void;
Parameter | |
---|---|
Name | Description |
callback |
ExistsInstanceConfigCallback
|
Returns | |
---|---|
Type | Description |
void |
formatName_(projectId, name)
static formatName_(projectId: string, name: string): string;
Format the instance config name to include the project ID.
Parameters | |
---|---|
Name | Description |
projectId |
string
The project ID. |
name |
string
The instance config name. |
Returns | |
---|---|
Type | Description |
string | {string} |
InstanceConfig.formatName_('grape-spaceship-123', 'my-instance-config');
// 'projects/grape-spaceship-123/instanceConfigs/my-instance-config'
get(options)
get(options?: GetInstanceConfigOptions): Promise<GetInstanceConfigResponse>;
Gets the metadata from the backend for this InstanceConfig.
Wrapper around .
Parameter | |
---|---|
Name | Description |
options |
GetInstanceConfigOptions
|
Returns | |
---|---|
Type | Description |
Promise<GetInstanceConfigResponse> | {Promise
|
const {Spanner} = require('@google-cloud/spanner');
const spanner = new Spanner();
const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
instanceConfig.get(function(err, instanceConfig) {
// `instanceConfig` is an instance configuration descriptor.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
instanceConfig.get().then(function(data) {
const instanceConfig = data[0];
});
get(callback)
get(callback: GetInstanceConfigCallback): void;
Parameter | |
---|---|
Name | Description |
callback |
GetInstanceConfigCallback
|
Returns | |
---|---|
Type | Description |
void |
get(options, callback)
get(options: GetInstanceConfigOptions, callback: GetInstanceConfigCallback): void;
Parameters | |
---|---|
Name | Description |
options |
GetInstanceConfigOptions
|
callback |
GetInstanceConfigCallback
|
Returns | |
---|---|
Type | Description |
void |
setMetadata(config)
setMetadata(config: SetInstanceConfigMetadataRequest): Promise<SetInstanceConfigMetadataResponse>;
Update the metadata for this instance config. Note that this method follows PATCH semantics, so previously-configured settings will persist. This function can only be called for deleting user managed instance configs.
Wrapper around .
Parameter | |
---|---|
Name | Description |
config |
SetInstanceConfigMetadataRequest
|
Returns | |
---|---|
Type | Description |
Promise<SetInstanceConfigMetadataResponse> | {Promise
|
const {Spanner} = require('@google-cloud/spanner');
const spanner = new Spanner();
const instanceConfig = spanner.instanceConfig('custom-my-instance-config');
const metadata = {
instanceConfig: {
displayName: 'My Instance Config'
}
};
instanceConfig.setMetadata(metadata, function(err, operation, apiResponse) {
if (err) {
// Error handling omitted.
}
operation
.on('error', function(err) {})
.on('complete', function() {
// Metadata updated successfully.
});
});
//-
// If the callback is omitted, we'll return a Promise.
//-
instanceConfig.setMetadata(metadata).then(function(data) {
const operation = data[0];
const apiResponse = data[1];
});
setMetadata(config, callback)
setMetadata(config: SetInstanceConfigMetadataRequest, callback: SetInstanceConfigMetadataCallback): void;
Parameters | |
---|---|
Name | Description |
config |
SetInstanceConfigMetadataRequest
|
callback |
SetInstanceConfigMetadataCallback
|
Returns | |
---|---|
Type | Description |
void |