v2. ConfigServiceV2Client
Source: v2/
Service for configuring sinks used to export log entries out of Logging.
Properties
Methods
new ConfigServiceV2Client([options])
Construct an instance of ConfigServiceV2Client.
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
|
Yes |
The configuration object. See the subsequent parameters for more details. Values in
|
Properties
apiEndpoint
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
The DNS address for this API service.
Methods
createExclusion(request[, options][, callback]) → Promise
Creates a new exclusion in a specified parent resource. Only log entries belonging to that resource can be excluded. You can have up to 10 exclusions in a resource.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedParent = client.projectPath('[PROJECT]');
const exclusion = {};
const request = {
parent: formattedParent,
exclusion: exclusion,
};
client.createExclusion(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
|
callback |
function(nullable Error, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing LogExclusion. |
- Returns
-
Promise- The promise which resolves to an array. The first element of the array is an object representing LogExclusion. The promise has a method named "cancel" which cancels the ongoing API call.
createSink(request[, options][, callback]) → Promise
Creates a sink that exports specified log entries to a destination. The
export of newly-ingested log entries begins immediately, unless the sink's
writer_identity is not permitted to write to the destination. A sink can
export log entries only from the resource owning the sink.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedParent = client.projectPath('[PROJECT]');
const sink = {};
const request = {
parent: formattedParent,
sink: sink,
};
client.createSink(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
|
callback |
function(nullable Error, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing LogSink. |
- Returns
-
Promise- The promise which resolves to an array. The first element of the array is an object representing LogSink. The promise has a method named "cancel" which cancels the ongoing API call.
deleteExclusion(request[, options][, callback]) → Promise
Deletes an exclusion.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedName = client.exclusionPath('[PROJECT]', '[EXCLUSION]');
client.deleteExclusion({name: formattedName}).catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
|
callback |
function(nullable Error) |
Yes |
The function which will be called with the result of the API call. |
- Returns
-
Promise- The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
deleteSink(request[, options][, callback]) → Promise
Deletes a sink. If the sink has a unique writer_identity, then that
service account is also deleted.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedSinkName = client.sinkPath('[PROJECT]', '[SINK]');
client.deleteSink({sinkName: formattedSinkName}).catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
|
callback |
function(nullable Error) |
Yes |
The function which will be called with the result of the API call. |
- Returns
-
Promise- The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
exclusionPath(project, exclusion) → String
Return a fully-qualified exclusion resource name string.
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
project |
String |
|
|
|
exclusion |
String |
|
- Returns
-
String
getExclusion(request[, options][, callback]) → Promise
Gets the description of an exclusion.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedName = client.exclusionPath('[PROJECT]', '[EXCLUSION]');
client.getExclusion({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
|
callback |
function(nullable Error, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing LogExclusion. |
- Returns
-
Promise- The promise which resolves to an array. The first element of the array is an object representing LogExclusion. The promise has a method named "cancel" which cancels the ongoing API call.
getProjectId(callback)
Return the project ID used by this class.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
callback |
function(Error, string) |
|
the callback to be called with the current project Id. |
getSink(request[, options][, callback]) → Promise
Gets a sink.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedSinkName = client.sinkPath('[PROJECT]', '[SINK]');
client.getSink({sinkName: formattedSinkName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
|
callback |
function(nullable Error, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing LogSink. |
- Returns
-
Promise- The promise which resolves to an array. The first element of the array is an object representing LogSink. The promise has a method named "cancel" which cancels the ongoing API call.
listExclusions(request[, options][, callback]) → Promise
Lists all the exclusions in a parent resource.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
// Iterate over all elements.
const formattedParent = client.projectPath('[PROJECT]');
client.listExclusions({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedParent = client.projectPath('[PROJECT]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listExclusions(nextRequest, options).then(callback);
}
}
client.listExclusions({parent: formattedParent}, options)
.then(callback)
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
|
callback |
function(nullable Error, nullable Array, nullable Object, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is Array of LogExclusion. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListExclusionsResponse. |
- Returns
-
Promise-
The promise which resolves to an array. The first element of the array is Array of LogExclusion.
When autoPaginate: false is specified through options, the array has three elements. The first element is Array of LogExclusion in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListExclusionsResponse.
The promise has a method named "cancel" which cancels the ongoing API call.
-
listExclusionsStream(request[, options]) → Stream
Equivalent to listExclusions, but returns a NodeJS Stream object.
This fetches the paged responses for listExclusions continuously and invokes the callback registered for 'data' event for each element in the responses.
The returned object has 'end' method when no more elements are required.
autoPaginate option will be ignored.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedParent = client.projectPath('[PROJECT]');
client.listExclusionsStream({parent: formattedParent})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
- See also
- https://nodejs.org/api/stream.html
- Returns
-
StreamAn object stream which emits an object representing LogExclusion on 'data' event.
listSinks(request[, options][, callback]) → Promise
Lists sinks.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
// Iterate over all elements.
const formattedParent = client.projectPath('[PROJECT]');
client.listSinks({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedParent = client.projectPath('[PROJECT]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listSinks(nextRequest, options).then(callback);
}
}
client.listSinks({parent: formattedParent}, options)
.then(callback)
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
|
callback |
function(nullable Error, nullable Array, nullable Object, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is Array of LogSink. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListSinksResponse. |
- Returns
-
Promise-
The promise which resolves to an array. The first element of the array is Array of LogSink.
When autoPaginate: false is specified through options, the array has three elements. The first element is Array of LogSink in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListSinksResponse.
The promise has a method named "cancel" which cancels the ongoing API call.
-
listSinksStream(request[, options]) → Stream
Equivalent to listSinks, but returns a NodeJS Stream object.
This fetches the paged responses for listSinks continuously and invokes the callback registered for 'data' event for each element in the responses.
The returned object has 'end' method when no more elements are required.
autoPaginate option will be ignored.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedParent = client.projectPath('[PROJECT]');
client.listSinksStream({parent: formattedParent})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
- See also
- https://nodejs.org/api/stream.html
- Returns
-
StreamAn object stream which emits an object representing LogSink on 'data' event.
matchExclusionFromExclusionName(exclusionName) → String
Parse the exclusionName from a exclusion resource.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
exclusionName |
String |
|
A fully-qualified path representing a exclusion resources. |
- Returns
-
String- A string representing the exclusion.
matchProjectFromExclusionName(exclusionName) → String
Parse the exclusionName from a exclusion resource.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
exclusionName |
String |
|
A fully-qualified path representing a exclusion resources. |
- Returns
-
String- A string representing the project.
matchProjectFromProjectName(projectName) → String
Parse the projectName from a project resource.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
projectName |
String |
|
A fully-qualified path representing a project resources. |
- Returns
-
String- A string representing the project.
matchProjectFromSinkName(sinkName) → String
Parse the sinkName from a sink resource.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
sinkName |
String |
|
A fully-qualified path representing a sink resources. |
- Returns
-
String- A string representing the project.
matchSinkFromSinkName(sinkName) → String
Parse the sinkName from a sink resource.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
sinkName |
String |
|
A fully-qualified path representing a sink resources. |
- Returns
-
String- A string representing the sink.
projectPath(project) → String
Return a fully-qualified project resource name string.
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
project |
String |
|
- Returns
-
String
sinkPath(project, sink) → String
Return a fully-qualified sink resource name string.
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
project |
String |
|
|
|
sink |
String |
|
- Returns
-
String
updateExclusion(request[, options][, callback]) → Promise
Changes one or more properties of an existing exclusion.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedName = client.exclusionPath('[PROJECT]', '[EXCLUSION]');
const exclusion = {};
const updateMask = {};
const request = {
name: formattedName,
exclusion: exclusion,
updateMask: updateMask,
};
client.updateExclusion(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
|
callback |
function(nullable Error, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing LogExclusion. |
- Returns
-
Promise- The promise which resolves to an array. The first element of the array is an object representing LogExclusion. The promise has a method named "cancel" which cancels the ongoing API call.
updateSink(request[, options][, callback]) → Promise
Updates a sink. This method replaces the following fields in the existing
sink with values from the new sink: destination, and filter.
The updated sink might also have a new writer_identity; see the
unique_writer_identity field.
Example
const logging = require('@google-cloud/logging');
const client = new logging.v2.ConfigServiceV2Client({
// optional auth parameters.
});
const formattedSinkName = client.sinkPath('[PROJECT]', '[SINK]');
const sink = {};
const request = {
sinkName: formattedSinkName,
sink: sink,
};
client.updateSink(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
Parameters
| Name | Type | Optional | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
request |
Object |
|
The request object that will be sent. Values in
|
||||||||||||||||||||
|
options |
Object |
Yes |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||||||
|
callback |
function(nullable Error, nullable Object) |
Yes |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing LogSink. |
- Returns
-
Promise- The promise which resolves to an array. The first element of the array is an object representing LogSink. The promise has a method named "cancel" which cancels the ongoing API call.