@Generated(value="by GAPIC v0.0.5") @BetaApi public class ConfigClient extends Object implements com.google.api.gax.core.BackgroundResource
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 (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
LogSink response = configClient.getSink(sinkName);
}
Note: close() needs to be called on the configClient 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 ConfigSettings to create(). For example:
ConfigSettings configSettings =
ConfigSettings.defaultBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ConfigClient configClient =
ConfigClient.create(configSettings);
| Modifier | Constructor and Description |
|---|---|
protected |
ConfigClient(ConfigServiceV2Stub stub) |
protected |
ConfigClient(ConfigSettings settings)
Constructs an instance of ConfigClient, using the given settings.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ConfigClient |
create()
Constructs an instance of ConfigClient with default settings.
|
static ConfigClient |
create(ConfigServiceV2Stub stub)
Constructs an instance of ConfigClient, using the given stub for making calls.
|
static ConfigClient |
create(ConfigSettings settings)
Constructs an instance of ConfigClient, using the given settings.
|
com.google.logging.v2.LogSink |
createSink(com.google.logging.v2.CreateSinkRequest request)
Creates a sink that exports specified log entries to a destination.
|
com.google.logging.v2.LogSink |
createSink(com.google.logging.v2.ParentNameOneof parent,
com.google.logging.v2.LogSink sink)
Creates a sink that exports specified log entries to a destination.
|
com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.CreateSinkRequest,com.google.logging.v2.LogSink> |
createSinkCallable()
Creates a sink that exports specified log entries to a destination.
|
void |
deleteSink(com.google.logging.v2.SinkNameOneof sinkName)
Deletes a sink.
|
com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.DeleteSinkRequest,com.google.protobuf.Empty> |
deleteSinkCallable()
Deletes a sink.
|
ConfigSettings |
getSettings() |
com.google.logging.v2.LogSink |
getSink(com.google.logging.v2.SinkNameOneof sinkName)
Gets a sink.
|
com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.GetSinkRequest,com.google.logging.v2.LogSink> |
getSinkCallable()
Gets a sink.
|
ConfigServiceV2Stub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
PagedResponseWrappers.ListSinksPagedResponse |
listSinks(com.google.logging.v2.ListSinksRequest request)
Lists sinks.
|
PagedResponseWrappers.ListSinksPagedResponse |
listSinks(com.google.logging.v2.ParentNameOneof parent)
Lists sinks.
|
com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.ListSinksRequest,com.google.logging.v2.ListSinksResponse> |
listSinksCallable()
Lists sinks.
|
com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.ListSinksRequest,PagedResponseWrappers.ListSinksPagedResponse> |
listSinksPagedCallable()
Lists sinks.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.logging.v2.LogSink |
updateSink(com.google.logging.v2.SinkNameOneof sinkName,
com.google.logging.v2.LogSink sink)
Updates a sink.
|
com.google.logging.v2.LogSink |
updateSink(com.google.logging.v2.UpdateSinkRequest request)
Updates a sink.
|
com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.UpdateSinkRequest,com.google.logging.v2.LogSink> |
updateSinkCallable()
Updates a sink.
|
protected ConfigClient(ConfigSettings settings) throws IOException
IOExceptionprotected ConfigClient(ConfigServiceV2Stub stub)
public static final ConfigClient create() throws IOException
IOExceptionpublic static final ConfigClient create(ConfigSettings settings) throws IOException
IOExceptionpublic static final ConfigClient create(ConfigServiceV2Stub stub)
public final ConfigSettings getSettings()
public ConfigServiceV2Stub getStub()
public final PagedResponseWrappers.ListSinksPagedResponse listSinks(com.google.logging.v2.ParentNameOneof parent)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
for (LogSink element : configClient.listSinks(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent resource whose sinks are to be listed:
"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]"
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PagedResponseWrappers.ListSinksPagedResponse listSinks(com.google.logging.v2.ListSinksRequest request)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
ListSinksRequest request = ListSinksRequest.newBuilder()
.setParentWithParentNameOneof(parent)
.build();
for (LogSink element : configClient.listSinks(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.ListSinksRequest,PagedResponseWrappers.ListSinksPagedResponse> listSinksPagedCallable()
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
ListSinksRequest request = ListSinksRequest.newBuilder()
.setParentWithParentNameOneof(parent)
.build();
ApiFuture<ListSinksPagedResponse> future = configClient.listSinksPagedCallable().futureCall(request);
// Do something
for (LogSink element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.ListSinksRequest,com.google.logging.v2.ListSinksResponse> listSinksCallable()
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
ListSinksRequest request = ListSinksRequest.newBuilder()
.setParentWithParentNameOneof(parent)
.build();
while (true) {
ListSinksResponse response = configClient.listSinksCallable().call(request);
for (LogSink element : response.getSinksList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.logging.v2.LogSink getSink(com.google.logging.v2.SinkNameOneof sinkName)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
LogSink response = configClient.getSink(sinkName);
}
sinkName - Required. The resource name of the sink:
"projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" "folders/[FOLDER_ID]/sinks/[SINK_ID]"
Example: `"projects/my-project-id/sinks/my-sink-id"`.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.GetSinkRequest,com.google.logging.v2.LogSink> getSinkCallable()
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
GetSinkRequest request = GetSinkRequest.newBuilder()
.setSinkNameWithSinkNameOneof(sinkName)
.build();
ApiFuture<LogSink> future = configClient.getSinkCallable().futureCall(request);
// Do something
LogSink response = future.get();
}
public final com.google.logging.v2.LogSink createSink(com.google.logging.v2.ParentNameOneof parent,
com.google.logging.v2.LogSink sink)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
LogSink sink = LogSink.newBuilder().build();
LogSink response = configClient.createSink(parent, sink);
}
parent - Required. The resource in which to create the sink:
"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]"
Examples: `"projects/my-logging-project"`, `"organizations/123456789"`.
sink - Required. The new sink, whose `name` parameter is a sink identifier that is not
already in use.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.logging.v2.LogSink createSink(com.google.logging.v2.CreateSinkRequest request)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
LogSink sink = LogSink.newBuilder().build();
CreateSinkRequest request = CreateSinkRequest.newBuilder()
.setParentWithParentNameOneof(parent)
.setSink(sink)
.build();
LogSink response = configClient.createSink(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.CreateSinkRequest,com.google.logging.v2.LogSink> createSinkCallable()
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
LogSink sink = LogSink.newBuilder().build();
CreateSinkRequest request = CreateSinkRequest.newBuilder()
.setParentWithParentNameOneof(parent)
.setSink(sink)
.build();
ApiFuture<LogSink> future = configClient.createSinkCallable().futureCall(request);
// Do something
LogSink response = future.get();
}
public final com.google.logging.v2.LogSink updateSink(com.google.logging.v2.SinkNameOneof sinkName,
com.google.logging.v2.LogSink sink)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
LogSink sink = LogSink.newBuilder().build();
LogSink response = configClient.updateSink(sinkName, sink);
}
sinkName - Required. The full resource name of the sink to update, including the parent
resource and the sink identifier:
"projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" "folders/[FOLDER_ID]/sinks/[SINK_ID]"
Example: `"projects/my-project-id/sinks/my-sink-id"`.
sink - Required. The updated sink, whose name is the same identifier that appears as part
of `sink_name`. If `sink_name` does not exist, then this method creates a new sink.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.logging.v2.LogSink updateSink(com.google.logging.v2.UpdateSinkRequest request)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
LogSink sink = LogSink.newBuilder().build();
UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
.setSinkNameWithSinkNameOneof(sinkName)
.setSink(sink)
.build();
LogSink response = configClient.updateSink(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.UpdateSinkRequest,com.google.logging.v2.LogSink> updateSinkCallable()
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
LogSink sink = LogSink.newBuilder().build();
UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
.setSinkNameWithSinkNameOneof(sinkName)
.setSink(sink)
.build();
ApiFuture<LogSink> future = configClient.updateSinkCallable().futureCall(request);
// Do something
LogSink response = future.get();
}
public final void deleteSink(com.google.logging.v2.SinkNameOneof sinkName)
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
configClient.deleteSink(sinkName);
}
sinkName - Required. The full resource name of the sink to delete, including the parent
resource and the sink identifier:
"projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" "folders/[FOLDER_ID]/sinks/[SINK_ID]"
Example: `"projects/my-project-id/sinks/my-sink-id"`.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.logging.v2.DeleteSinkRequest,com.google.protobuf.Empty> deleteSinkCallable()
Sample code:
try (ConfigClient configClient = ConfigClient.create()) {
SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
DeleteSinkRequest request = DeleteSinkRequest.newBuilder()
.setSinkNameWithSinkNameOneof(sinkName)
.build();
ApiFuture<Void> future = configClient.deleteSinkCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
throws Exception
close in interface AutoCloseableExceptionpublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2017 Google. All rights reserved.