@Generated(value="by gapic-generator") @BetaApi public class ErrorStatsServiceClient 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 (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(projectName);
}
Note: close() needs to be called on the errorStatsServiceClient 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 ErrorStatsServiceSettings to create(). For example:
To customize credentials:
ErrorStatsServiceSettings errorStatsServiceSettings =
ErrorStatsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ErrorStatsServiceClient errorStatsServiceClient =
ErrorStatsServiceClient.create(errorStatsServiceSettings);
To customize the endpoint:
ErrorStatsServiceSettings errorStatsServiceSettings =
ErrorStatsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ErrorStatsServiceClient errorStatsServiceClient =
ErrorStatsServiceClient.create(errorStatsServiceSettings);
Modifier and Type | Class and Description |
---|---|
static class |
ErrorStatsServiceClient.ListEventsFixedSizeCollection |
static class |
ErrorStatsServiceClient.ListEventsPage |
static class |
ErrorStatsServiceClient.ListEventsPagedResponse |
static class |
ErrorStatsServiceClient.ListGroupStatsFixedSizeCollection |
static class |
ErrorStatsServiceClient.ListGroupStatsPage |
static class |
ErrorStatsServiceClient.ListGroupStatsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ErrorStatsServiceClient(ErrorStatsServiceSettings settings)
Constructs an instance of ErrorStatsServiceClient, using the given settings.
|
protected |
ErrorStatsServiceClient(ErrorStatsServiceStub stub) |
protected ErrorStatsServiceClient(ErrorStatsServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ErrorStatsServiceClient(ErrorStatsServiceStub stub)
public static final ErrorStatsServiceClient create() throws IOException
IOException
public static final ErrorStatsServiceClient create(ErrorStatsServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ErrorStatsServiceClient create(ErrorStatsServiceStub stub)
public final ErrorStatsServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ErrorStatsServiceStub getStub()
public final ErrorStatsServiceClient.ListGroupStatsPagedResponse listGroupStats(ProjectName projectName, QueryTimeRange timeRange)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
for (ErrorGroupStats element : errorStatsServiceClient.listGroupStats(projectName, timeRange).iterateAll()) {
// doThingsWith(element);
}
}
projectName
- [Required] The resource name of the Google Cloud Platform project. Written
as <code>projects/</code> plus the <a
href="https://support.google.com/cloud/answer/6158840">Google Cloud Platform project
ID</a>.
Example: <code>projects/my-project-123</code>.
timeRange
- [Optional] List data for the given time range. If not set a default time range
is used. The field time_range_begin in the response will specify the beginning of this time
range. Only <code>ErrorGroupStats</code> with a non-zero count in the given
time range are returned, unless the request contains an explicit group_id list. If a
group_id list is given, also <code>ErrorGroupStats</code> with zero occurrences
are returned.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ErrorStatsServiceClient.ListGroupStatsPagedResponse listGroupStats(String projectName, QueryTimeRange timeRange)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
for (ErrorGroupStats element : errorStatsServiceClient.listGroupStats(projectName.toString(), timeRange).iterateAll()) {
// doThingsWith(element);
}
}
projectName
- [Required] The resource name of the Google Cloud Platform project. Written
as <code>projects/</code> plus the <a
href="https://support.google.com/cloud/answer/6158840">Google Cloud Platform project
ID</a>.
Example: <code>projects/my-project-123</code>.
timeRange
- [Optional] List data for the given time range. If not set a default time range
is used. The field time_range_begin in the response will specify the beginning of this time
range. Only <code>ErrorGroupStats</code> with a non-zero count in the given
time range are returned, unless the request contains an explicit group_id list. If a
group_id list is given, also <code>ErrorGroupStats</code> with zero occurrences
are returned.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ErrorStatsServiceClient.ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest request)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder()
.setProjectName(projectName.toString())
.setTimeRange(timeRange)
.build();
for (ErrorGroupStats element : errorStatsServiceClient.listGroupStats(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<ListGroupStatsRequest,ErrorStatsServiceClient.ListGroupStatsPagedResponse> listGroupStatsPagedCallable()
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder()
.setProjectName(projectName.toString())
.setTimeRange(timeRange)
.build();
ApiFuture<ListGroupStatsPagedResponse> future = errorStatsServiceClient.listGroupStatsPagedCallable().futureCall(request);
// Do something
for (ErrorGroupStats element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListGroupStatsRequest,ListGroupStatsResponse> listGroupStatsCallable()
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder()
.setProjectName(projectName.toString())
.setTimeRange(timeRange)
.build();
while (true) {
ListGroupStatsResponse response = errorStatsServiceClient.listGroupStatsCallable().call(request);
for (ErrorGroupStats element : response.getErrorGroupStatsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final ErrorStatsServiceClient.ListEventsPagedResponse listEvents(ProjectName projectName, String groupId)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
String groupId = "";
for (ErrorEvent element : errorStatsServiceClient.listEvents(projectName, groupId).iterateAll()) {
// doThingsWith(element);
}
}
projectName
- [Required] The resource name of the Google Cloud Platform project. Written
as `projects/` plus the [Google Cloud Platform project
ID](https://support.google.com/cloud/answer/6158840). Example: `projects/my-project-123`.groupId
- [Required] The group for which events shall be returned.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ErrorStatsServiceClient.ListEventsPagedResponse listEvents(String projectName, String groupId)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
String groupId = "";
for (ErrorEvent element : errorStatsServiceClient.listEvents(projectName.toString(), groupId).iterateAll()) {
// doThingsWith(element);
}
}
projectName
- [Required] The resource name of the Google Cloud Platform project. Written
as `projects/` plus the [Google Cloud Platform project
ID](https://support.google.com/cloud/answer/6158840). Example: `projects/my-project-123`.groupId
- [Required] The group for which events shall be returned.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ErrorStatsServiceClient.ListEventsPagedResponse listEvents(ListEventsRequest request)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
String groupId = "";
ListEventsRequest request = ListEventsRequest.newBuilder()
.setProjectName(projectName.toString())
.setGroupId(groupId)
.build();
for (ErrorEvent element : errorStatsServiceClient.listEvents(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<ListEventsRequest,ErrorStatsServiceClient.ListEventsPagedResponse> listEventsPagedCallable()
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
String groupId = "";
ListEventsRequest request = ListEventsRequest.newBuilder()
.setProjectName(projectName.toString())
.setGroupId(groupId)
.build();
ApiFuture<ListEventsPagedResponse> future = errorStatsServiceClient.listEventsPagedCallable().futureCall(request);
// Do something
for (ErrorEvent element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListEventsRequest,ListEventsResponse> listEventsCallable()
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
String groupId = "";
ListEventsRequest request = ListEventsRequest.newBuilder()
.setProjectName(projectName.toString())
.setGroupId(groupId)
.build();
while (true) {
ListEventsResponse response = errorStatsServiceClient.listEventsCallable().call(request);
for (ErrorEvent element : response.getErrorEventsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final DeleteEventsResponse deleteEvents(ProjectName projectName)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(projectName);
}
projectName
- [Required] The resource name of the Google Cloud Platform project. Written
as `projects/` plus the [Google Cloud Platform project
ID](https://support.google.com/cloud/answer/6158840). Example: `projects/my-project-123`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final DeleteEventsResponse deleteEvents(String projectName)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(projectName.toString());
}
projectName
- [Required] The resource name of the Google Cloud Platform project. Written
as `projects/` plus the [Google Cloud Platform project
ID](https://support.google.com/cloud/answer/6158840). Example: `projects/my-project-123`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final DeleteEventsResponse deleteEvents(DeleteEventsRequest request)
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
DeleteEventsRequest request = DeleteEventsRequest.newBuilder()
.setProjectName(projectName.toString())
.build();
DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(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<DeleteEventsRequest,DeleteEventsResponse> deleteEventsCallable()
Sample code:
try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
ProjectName projectName = ProjectName.of("[PROJECT]");
DeleteEventsRequest request = DeleteEventsRequest.newBuilder()
.setProjectName(projectName.toString())
.build();
ApiFuture<DeleteEventsResponse> future = errorStatsServiceClient.deleteEventsCallable().futureCall(request);
// Do something
DeleteEventsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.