@Generated(value="by GAPIC") public class ConfigServiceV2Api extends Object implements AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
ListSinksResponse response = configServiceV2Api.listSinks(formattedProjectName);
}
Note: close() needs to be called on the configServiceV2Api object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ConfigServiceV2Settings to create(). For example:
ConfigServiceV2Settings configServiceV2Settings = ConfigServiceV2Settings.defaultBuilder()
.provideChannelWith(myCredentials)
.build();
ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create(configServiceV2Settings);
| Modifier | Constructor and Description |
|---|---|
protected |
ConfigServiceV2Api(ConfigServiceV2Settings settings)
Constructs an instance of ConfigServiceV2Api, using the given settings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
cancelled.
|
static ConfigServiceV2Api |
create(ConfigServiceV2Settings settings)
Constructs an instance of ConfigServiceV2Api, using the given settings.
|
com.google.logging.v2.LogSink |
createSink(com.google.logging.v2.CreateSinkRequest request)
Creates a sink.
|
com.google.logging.v2.LogSink |
createSink(String projectName,
com.google.logging.v2.LogSink sink)
Creates a sink.
|
com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.CreateSinkRequest,com.google.logging.v2.LogSink> |
createSinkCallable()
Creates a sink.
|
static ConfigServiceV2Api |
createWithDefaults()
Constructs an instance of ConfigServiceV2Api with default settings.
|
void |
deleteSink(String sinkName)
Deletes a sink.
|
com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.DeleteSinkRequest,com.google.protobuf.Empty> |
deleteSinkCallable()
Deletes a sink.
|
static String |
formatProjectName(String project)
Formats a string containing the fully-qualified path to represent
a project resource.
|
static String |
formatSinkName(String project,
String sink)
Formats a string containing the fully-qualified path to represent
a sink resource.
|
ConfigServiceV2Settings |
getSettings() |
com.google.logging.v2.LogSink |
getSink(String sinkName)
Gets a sink.
|
com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.GetSinkRequest,com.google.logging.v2.LogSink> |
getSinkCallable()
Gets a sink.
|
com.google.api.gax.core.PageAccessor<com.google.logging.v2.LogSink> |
listSinks(com.google.logging.v2.ListSinksRequest request)
Lists sinks.
|
com.google.api.gax.core.PageAccessor<com.google.logging.v2.LogSink> |
listSinks(String projectName)
Lists sinks.
|
com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.ListSinksRequest,com.google.logging.v2.ListSinksResponse> |
listSinksCallable()
Lists sinks.
|
com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.ListSinksRequest,com.google.api.gax.core.PageAccessor<com.google.logging.v2.LogSink>> |
listSinksPagedCallable()
Lists sinks.
|
static String |
parseProjectFromProjectName(String projectName)
Parses the project from the given fully-qualified path which
represents a project resource.
|
static String |
parseProjectFromSinkName(String sinkName)
Parses the project from the given fully-qualified path which
represents a sink resource.
|
static String |
parseSinkFromSinkName(String sinkName)
Parses the sink from the given fully-qualified path which
represents a sink resource.
|
com.google.logging.v2.LogSink |
updateSink(String sinkName,
com.google.logging.v2.LogSink sink)
Creates or updates a sink.
|
com.google.logging.v2.LogSink |
updateSink(com.google.logging.v2.UpdateSinkRequest request)
Creates or updates a sink.
|
com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.UpdateSinkRequest,com.google.logging.v2.LogSink> |
updateSinkCallable()
Creates or updates a sink.
|
protected ConfigServiceV2Api(ConfigServiceV2Settings settings) throws IOException
IOExceptionpublic final ConfigServiceV2Settings getSettings()
public static final String formatProjectName(String project)
public static final String formatSinkName(String project, String sink)
public static final String parseProjectFromProjectName(String projectName)
public static final String parseProjectFromSinkName(String sinkName)
public static final String parseSinkFromSinkName(String sinkName)
public static final ConfigServiceV2Api createWithDefaults() throws IOException
IOExceptionpublic static final ConfigServiceV2Api create(ConfigServiceV2Settings settings) throws IOException
IOExceptionpublic final com.google.api.gax.core.PageAccessor<com.google.logging.v2.LogSink> listSinks(String projectName)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
for (LogSink elements : configServiceV2Api.listSinks(formattedProjectName)) {
// doThingsWith(elements);
}
}
projectName - Required. The resource name of the project containing the sinks.
Example: `"projects/my-logging-project"`, `"projects/01234567890"`.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.core.PageAccessor<com.google.logging.v2.LogSink> listSinks(com.google.logging.v2.ListSinksRequest request)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
ListSinksRequest request = ListSinksRequest.newBuilder()
.setProjectName(formattedProjectName)
.build();
for (LogSink elements : configServiceV2Api.listSinks(request)) {
// doThingsWith(elements);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.ListSinksRequest,com.google.api.gax.core.PageAccessor<com.google.logging.v2.LogSink>> listSinksPagedCallable()
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
ListSinksRequest request = ListSinksRequest.newBuilder()
.setProjectName(formattedProjectName)
.build();
ListenableFuture<PageAccessor<LogSink>> future = configServiceV2Api.listSinksPagedCallable().futureCall(request);
// Do something
for (LogSink elements : future.get()) {
// doThingsWith(elements);
}
}
public final com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.ListSinksRequest,com.google.logging.v2.ListSinksResponse> listSinksCallable()
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
ListSinksRequest request = ListSinksRequest.newBuilder()
.setProjectName(formattedProjectName)
.build();
while (true) {
ListSinksResponse response = configServiceV2Api.listSinksCallable().call(request);
for (LogSink elements : response.getSinksList()) {
// doThingsWith(elements);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.logging.v2.LogSink getSink(String sinkName)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
LogSink response = configServiceV2Api.getSink(formattedSinkName);
}
sinkName - The resource name of the sink to return.
Example: `"projects/my-project-id/sinks/my-sink-id"`.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.GetSinkRequest,com.google.logging.v2.LogSink> getSinkCallable()
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
GetSinkRequest request = GetSinkRequest.newBuilder()
.setSinkName(formattedSinkName)
.build();
ListenableFuture<LogSink> future = configServiceV2Api.getSinkCallable().futureCall(request);
// Do something
LogSink response = future.get();
}
public final com.google.logging.v2.LogSink createSink(String projectName, com.google.logging.v2.LogSink sink)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
LogSink sink = LogSink.newBuilder().build();
LogSink response = configServiceV2Api.createSink(formattedProjectName, sink);
}
projectName - The resource name of the project in which to create the sink.
Example: `"projects/my-project-id"`.
The new sink must be provided in the request.sink - The new sink, which must not have an identifier that already
exists.com.google.api.gax.grpc.ApiException - if the remote call failspublic com.google.logging.v2.LogSink createSink(com.google.logging.v2.CreateSinkRequest request)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
LogSink sink = LogSink.newBuilder().build();
CreateSinkRequest request = CreateSinkRequest.newBuilder()
.setProjectName(formattedProjectName)
.setSink(sink)
.build();
LogSink response = configServiceV2Api.createSink(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.CreateSinkRequest,com.google.logging.v2.LogSink> createSinkCallable()
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedProjectName = ConfigServiceV2Api.formatProjectName("[PROJECT]");
LogSink sink = LogSink.newBuilder().build();
CreateSinkRequest request = CreateSinkRequest.newBuilder()
.setProjectName(formattedProjectName)
.setSink(sink)
.build();
ListenableFuture<LogSink> future = configServiceV2Api.createSinkCallable().futureCall(request);
// Do something
LogSink response = future.get();
}
public final com.google.logging.v2.LogSink updateSink(String sinkName, com.google.logging.v2.LogSink sink)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
LogSink sink = LogSink.newBuilder().build();
LogSink response = configServiceV2Api.updateSink(formattedSinkName, sink);
}
sinkName - The resource name of the sink to update.
Example: `"projects/my-project-id/sinks/my-sink-id"`.
The updated sink must be provided in the request and have the
same name that is specified in `sinkName`. If the sink does not
exist, it is created.sink - The updated sink, whose name must be the same as the sink
identifier in `sinkName`. If `sinkName` does not exist, then
this method creates a new sink.com.google.api.gax.grpc.ApiException - if the remote call failspublic com.google.logging.v2.LogSink updateSink(com.google.logging.v2.UpdateSinkRequest request)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
LogSink sink = LogSink.newBuilder().build();
UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
.setSinkName(formattedSinkName)
.setSink(sink)
.build();
LogSink response = configServiceV2Api.updateSink(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.UpdateSinkRequest,com.google.logging.v2.LogSink> updateSinkCallable()
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
LogSink sink = LogSink.newBuilder().build();
UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
.setSinkName(formattedSinkName)
.setSink(sink)
.build();
ListenableFuture<LogSink> future = configServiceV2Api.updateSinkCallable().futureCall(request);
// Do something
LogSink response = future.get();
}
public final void deleteSink(String sinkName)
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
configServiceV2Api.deleteSink(formattedSinkName);
}
sinkName - The resource name of the sink to delete.
Example: `"projects/my-project-id/sinks/my-sink-id"`.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.ApiCallable<com.google.logging.v2.DeleteSinkRequest,com.google.protobuf.Empty> deleteSinkCallable()
try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.createWithDefaults()) {
String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
DeleteSinkRequest request = DeleteSinkRequest.newBuilder()
.setSinkName(formattedSinkName)
.build();
ListenableFuture<Void> future = configServiceV2Api.deleteSinkCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
throws Exception
close in interface AutoCloseableExceptionCopyright © 2016 Google. All rights reserved.