@Generated(value="by gapic-generator") @BetaApi public class RealmsServiceClient extends Object implements 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 (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
Realm response = realmsServiceClient.getRealm(formattedName);
}
Note: close() needs to be called on the realmsServiceClient 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 RealmsServiceSettings to create(). For example:
To customize credentials:
RealmsServiceSettings realmsServiceSettings =
RealmsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RealmsServiceClient realmsServiceClient =
RealmsServiceClient.create(realmsServiceSettings);
To customize the endpoint:
RealmsServiceSettings realmsServiceSettings =
RealmsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
RealmsServiceClient realmsServiceClient =
RealmsServiceClient.create(realmsServiceSettings);
Modifier and Type | Class and Description |
---|---|
static class |
RealmsServiceClient.ListRealmsFixedSizeCollection |
static class |
RealmsServiceClient.ListRealmsPage |
static class |
RealmsServiceClient.ListRealmsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
RealmsServiceClient(RealmsServiceSettings settings)
Constructs an instance of RealmsServiceClient, using the given settings.
|
protected |
RealmsServiceClient(RealmsServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static RealmsServiceClient |
create()
Constructs an instance of RealmsServiceClient with default settings.
|
static RealmsServiceClient |
create(RealmsServiceSettings settings)
Constructs an instance of RealmsServiceClient, using the given settings.
|
static RealmsServiceClient |
create(RealmsServiceStub stub)
Constructs an instance of RealmsServiceClient, using the given stub for making calls.
|
OperationFuture<Realm,Empty> |
createRealmAsync(CreateRealmRequest request)
Creates a new Realm in a given project and location.
|
OperationFuture<Realm,Empty> |
createRealmAsync(String parent,
String realmId,
Realm realm)
Creates a new Realm in a given project and location.
|
UnaryCallable<CreateRealmRequest,Operation> |
createRealmCallable()
Creates a new Realm in a given project and location.
|
OperationCallable<CreateRealmRequest,Realm,Empty> |
createRealmOperationCallable()
Creates a new Realm in a given project and location.
|
OperationFuture<Empty,Empty> |
deleteRealmAsync(DeleteRealmRequest request)
Deletes a single realm.
|
OperationFuture<Empty,Empty> |
deleteRealmAsync(String name)
Deletes a single realm.
|
UnaryCallable<DeleteRealmRequest,Operation> |
deleteRealmCallable()
Deletes a single realm.
|
OperationCallable<DeleteRealmRequest,Empty,Empty> |
deleteRealmOperationCallable()
Deletes a single realm.
|
static String |
formatLocationName(String project,
String location)
Deprecated.
Use the
LocationName class instead. |
static String |
formatRealmName(String project,
String location,
String realm)
Deprecated.
Use the
RealmName class instead. |
OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
Realm |
getRealm(GetRealmRequest request)
Gets details of a single realm.
|
Realm |
getRealm(String name)
Gets details of a single realm.
|
UnaryCallable<GetRealmRequest,Realm> |
getRealmCallable()
Gets details of a single realm.
|
RealmsServiceSettings |
getSettings() |
RealmsServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
RealmsServiceClient.ListRealmsPagedResponse |
listRealms(ListRealmsRequest request)
Lists realms in a given project and location.
|
RealmsServiceClient.ListRealmsPagedResponse |
listRealms(String parent)
Lists realms in a given project and location.
|
UnaryCallable<ListRealmsRequest,ListRealmsResponse> |
listRealmsCallable()
Lists realms in a given project and location.
|
UnaryCallable<ListRealmsRequest,RealmsServiceClient.ListRealmsPagedResponse> |
listRealmsPagedCallable()
Lists realms in a given project and location.
|
static String |
parseLocationFromLocationName(String locationName)
Deprecated.
Use the
LocationName class instead. |
static String |
parseLocationFromRealmName(String realmName)
Deprecated.
Use the
RealmName class instead. |
static String |
parseProjectFromLocationName(String locationName)
Deprecated.
Use the
LocationName class instead. |
static String |
parseProjectFromRealmName(String realmName)
Deprecated.
Use the
RealmName class instead. |
static String |
parseRealmFromRealmName(String realmName)
Deprecated.
Use the
RealmName class instead. |
PreviewRealmUpdateResponse |
previewRealmUpdate(PreviewRealmUpdateRequest request)
Previews patches to a single Realm.
|
UnaryCallable<PreviewRealmUpdateRequest,PreviewRealmUpdateResponse> |
previewRealmUpdateCallable()
Previews patches to a single Realm.
|
void |
shutdown() |
void |
shutdownNow() |
OperationFuture<Realm,Empty> |
updateRealmAsync(Realm realm,
FieldMask updateMask)
Patches a single Realm.
|
OperationFuture<Realm,Empty> |
updateRealmAsync(UpdateRealmRequest request)
Patches a single Realm.
|
UnaryCallable<UpdateRealmRequest,Operation> |
updateRealmCallable()
Patches a single Realm.
|
OperationCallable<UpdateRealmRequest,Realm,Empty> |
updateRealmOperationCallable()
Patches a single Realm.
|
protected RealmsServiceClient(RealmsServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected RealmsServiceClient(RealmsServiceStub stub)
@Deprecated public static final String formatLocationName(String project, String location)
LocationName
class instead.@Deprecated public static final String formatRealmName(String project, String location, String realm)
RealmName
class instead.@Deprecated public static final String parseProjectFromLocationName(String locationName)
LocationName
class instead.@Deprecated public static final String parseLocationFromLocationName(String locationName)
LocationName
class instead.@Deprecated public static final String parseProjectFromRealmName(String realmName)
RealmName
class instead.@Deprecated public static final String parseLocationFromRealmName(String realmName)
RealmName
class instead.@Deprecated public static final String parseRealmFromRealmName(String realmName)
RealmName
class instead.public static final RealmsServiceClient create() throws IOException
IOException
public static final RealmsServiceClient create(RealmsServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final RealmsServiceClient create(RealmsServiceStub stub)
public final RealmsServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public RealmsServiceStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient()
public final RealmsServiceClient.ListRealmsPagedResponse listRealms(String parent)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
for (Realm element : realmsServiceClient.listRealms(formattedParent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The parent resource name, using the form:
`projects/{project}/locations/{location}`.ApiException
- if the remote call failspublic final RealmsServiceClient.ListRealmsPagedResponse listRealms(ListRealmsRequest request)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
ListRealmsRequest request = ListRealmsRequest.newBuilder()
.setParent(formattedParent)
.build();
for (Realm element : realmsServiceClient.listRealms(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListRealmsRequest,RealmsServiceClient.ListRealmsPagedResponse> listRealmsPagedCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
ListRealmsRequest request = ListRealmsRequest.newBuilder()
.setParent(formattedParent)
.build();
ApiFuture<ListRealmsPagedResponse> future = realmsServiceClient.listRealmsPagedCallable().futureCall(request);
// Do something
for (Realm element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListRealmsRequest,ListRealmsResponse> listRealmsCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
ListRealmsRequest request = ListRealmsRequest.newBuilder()
.setParent(formattedParent)
.build();
while (true) {
ListRealmsResponse response = realmsServiceClient.listRealmsCallable().call(request);
for (Realm element : response.getRealmsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Realm getRealm(String name)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
Realm response = realmsServiceClient.getRealm(formattedName);
}
name
- Required. The name of the realm to retrieve, using the form:
`projects/{project}/locations/{location}/realms/{realm}`ApiException
- if the remote call failspublic final Realm getRealm(GetRealmRequest request)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
GetRealmRequest request = GetRealmRequest.newBuilder()
.setName(formattedName)
.build();
Realm response = realmsServiceClient.getRealm(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetRealmRequest,Realm> getRealmCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
GetRealmRequest request = GetRealmRequest.newBuilder()
.setName(formattedName)
.build();
ApiFuture<Realm> future = realmsServiceClient.getRealmCallable().futureCall(request);
// Do something
Realm response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Realm,Empty> createRealmAsync(String parent, String realmId, Realm realm)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
String realmId = "";
Realm realm = Realm.newBuilder().build();
Realm response = realmsServiceClient.createRealmAsync(formattedParent, realmId, realm).get();
}
parent
- Required. The parent resource name, using the form:
`projects/{project}/locations/{location}`.realmId
- Required. The ID of the realm resource to be created.realm
- Required. The realm resource to be created.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Realm,Empty> createRealmAsync(CreateRealmRequest request)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
String realmId = "";
Realm realm = Realm.newBuilder().build();
CreateRealmRequest request = CreateRealmRequest.newBuilder()
.setParent(formattedParent)
.setRealmId(realmId)
.setRealm(realm)
.build();
Realm response = realmsServiceClient.createRealmAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<CreateRealmRequest,Realm,Empty> createRealmOperationCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
String realmId = "";
Realm realm = Realm.newBuilder().build();
CreateRealmRequest request = CreateRealmRequest.newBuilder()
.setParent(formattedParent)
.setRealmId(realmId)
.setRealm(realm)
.build();
OperationFuture<Realm, Empty> future = realmsServiceClient.createRealmOperationCallable().futureCall(request);
// Do something
Realm response = future.get();
}
public final UnaryCallable<CreateRealmRequest,Operation> createRealmCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedParent = RealmsServiceClient.formatLocationName("[PROJECT]", "[LOCATION]");
String realmId = "";
Realm realm = Realm.newBuilder().build();
CreateRealmRequest request = CreateRealmRequest.newBuilder()
.setParent(formattedParent)
.setRealmId(realmId)
.setRealm(realm)
.build();
ApiFuture<Operation> future = realmsServiceClient.createRealmCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,Empty> deleteRealmAsync(String name)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
realmsServiceClient.deleteRealmAsync(formattedName).get();
}
name
- Required. The name of the realm to delete, using the form:
`projects/{project}/locations/{location}/realms/{realm}`ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,Empty> deleteRealmAsync(DeleteRealmRequest request)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
DeleteRealmRequest request = DeleteRealmRequest.newBuilder()
.setName(formattedName)
.build();
realmsServiceClient.deleteRealmAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<DeleteRealmRequest,Empty,Empty> deleteRealmOperationCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
DeleteRealmRequest request = DeleteRealmRequest.newBuilder()
.setName(formattedName)
.build();
OperationFuture<Empty, Empty> future = realmsServiceClient.deleteRealmOperationCallable().futureCall(request);
// Do something
future.get();
}
public final UnaryCallable<DeleteRealmRequest,Operation> deleteRealmCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
String formattedName = RealmsServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
DeleteRealmRequest request = DeleteRealmRequest.newBuilder()
.setName(formattedName)
.build();
ApiFuture<Operation> future = realmsServiceClient.deleteRealmCallable().futureCall(request);
// Do something
future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Realm,Empty> updateRealmAsync(Realm realm, FieldMask updateMask)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
Realm realm = Realm.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Realm response = realmsServiceClient.updateRealmAsync(realm, updateMask).get();
}
realm
- Required. The realm to be updated. Only fields specified in update_mask are
updated.updateMask
- Required. The update mask applies to the resource. For the `FieldMask`
definition, see
https: //developers.google.com/protocol-buffers // /docs/reference/google.protobuf#fieldmask
ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Realm,Empty> updateRealmAsync(UpdateRealmRequest request)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
Realm realm = Realm.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateRealmRequest request = UpdateRealmRequest.newBuilder()
.setRealm(realm)
.setUpdateMask(updateMask)
.build();
Realm response = realmsServiceClient.updateRealmAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<UpdateRealmRequest,Realm,Empty> updateRealmOperationCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
Realm realm = Realm.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateRealmRequest request = UpdateRealmRequest.newBuilder()
.setRealm(realm)
.setUpdateMask(updateMask)
.build();
OperationFuture<Realm, Empty> future = realmsServiceClient.updateRealmOperationCallable().futureCall(request);
// Do something
Realm response = future.get();
}
public final UnaryCallable<UpdateRealmRequest,Operation> updateRealmCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
Realm realm = Realm.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateRealmRequest request = UpdateRealmRequest.newBuilder()
.setRealm(realm)
.setUpdateMask(updateMask)
.build();
ApiFuture<Operation> future = realmsServiceClient.updateRealmCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final PreviewRealmUpdateResponse previewRealmUpdate(PreviewRealmUpdateRequest request)
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
PreviewRealmUpdateRequest request = PreviewRealmUpdateRequest.newBuilder().build();
PreviewRealmUpdateResponse response = realmsServiceClient.previewRealmUpdate(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<PreviewRealmUpdateRequest,PreviewRealmUpdateResponse> previewRealmUpdateCallable()
Sample code:
try (RealmsServiceClient realmsServiceClient = RealmsServiceClient.create()) {
PreviewRealmUpdateRequest request = PreviewRealmUpdateRequest.newBuilder().build();
ApiFuture<PreviewRealmUpdateResponse> future = realmsServiceClient.previewRealmUpdateCallable().futureCall(request);
// Do something
PreviewRealmUpdateResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2020 Google LLC. All rights reserved.