Class ProfileServiceClient

public class ProfileServiceClient implements BackgroundResource

Service Description: A service that handles profile management, including profile CRUD, enumeration and search.

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 (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
   Profile profile = Profile.newBuilder().build();
   Profile response = profileServiceClient.createProfile(parent, profile);
 }
 

Note: close() needs to be called on the ProfileServiceClient 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:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

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 ProfileServiceSettings to create(). For example:

To customize credentials:


 ProfileServiceSettings profileServiceSettings =
     ProfileServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ProfileServiceClient profileServiceClient = ProfileServiceClient.create(profileServiceSettings);
 

To customize the endpoint:


 ProfileServiceSettings profileServiceSettings =
     ProfileServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ProfileServiceClient profileServiceClient = ProfileServiceClient.create(profileServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ProfileServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final ProfileServiceClient create()

Constructs an instance of ProfileServiceClient with default settings.

Returns
TypeDescription
ProfileServiceClient
Exceptions
TypeDescription
IOException

create(ProfileServiceSettings settings)

public static final ProfileServiceClient create(ProfileServiceSettings settings)

Constructs an instance of ProfileServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsProfileServiceSettings
Returns
TypeDescription
ProfileServiceClient
Exceptions
TypeDescription
IOException

create(ProfileServiceStub stub)

public static final ProfileServiceClient create(ProfileServiceStub stub)

Constructs an instance of ProfileServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ProfileServiceSettings).

Parameter
NameDescription
stubProfileServiceStub
Returns
TypeDescription
ProfileServiceClient

Constructors

ProfileServiceClient(ProfileServiceSettings settings)

protected ProfileServiceClient(ProfileServiceSettings settings)

Constructs an instance of ProfileServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsProfileServiceSettings

ProfileServiceClient(ProfileServiceStub stub)

protected ProfileServiceClient(ProfileServiceStub stub)
Parameter
NameDescription
stubProfileServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createProfile(CreateProfileRequest request)

public final Profile createProfile(CreateProfileRequest request)

Creates and returns a new profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   CreateProfileRequest request =
       CreateProfileRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setProfile(Profile.newBuilder().build())
           .build();
   Profile response = profileServiceClient.createProfile(request);
 }
 
Parameter
NameDescription
requestCreateProfileRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Profile

createProfile(TenantName parent, Profile profile)

public final Profile createProfile(TenantName parent, Profile profile)

Creates and returns a new profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
   Profile profile = Profile.newBuilder().build();
   Profile response = profileServiceClient.createProfile(parent, profile);
 }
 
Parameters
NameDescription
parentTenantName

Required. The name of the tenant this profile belongs to.

The format is "projects/{project_id}/tenants/{tenant_id}". For example, "projects/foo/tenants/bar".

profileProfile

Required. The profile to be created.

Returns
TypeDescription
Profile

createProfile(String parent, Profile profile)

public final Profile createProfile(String parent, Profile profile)

Creates and returns a new profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   String parent = TenantName.of("[PROJECT]", "[TENANT]").toString();
   Profile profile = Profile.newBuilder().build();
   Profile response = profileServiceClient.createProfile(parent, profile);
 }
 
Parameters
NameDescription
parentString

Required. The name of the tenant this profile belongs to.

The format is "projects/{project_id}/tenants/{tenant_id}". For example, "projects/foo/tenants/bar".

profileProfile

Required. The profile to be created.

Returns
TypeDescription
Profile

createProfileCallable()

public final UnaryCallable<CreateProfileRequest,Profile> createProfileCallable()

Creates and returns a new profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   CreateProfileRequest request =
       CreateProfileRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setProfile(Profile.newBuilder().build())
           .build();
   ApiFuture<Profile> future = profileServiceClient.createProfileCallable().futureCall(request);
   // Do something.
   Profile response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateProfileRequest,Profile>

deleteProfile(DeleteProfileRequest request)

public final void deleteProfile(DeleteProfileRequest request)

Deletes the specified profile. Prerequisite: The profile has no associated applications or assignments associated.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   DeleteProfileRequest request =
       DeleteProfileRequest.newBuilder()
           .setName(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .build();
   profileServiceClient.deleteProfile(request);
 }
 
Parameter
NameDescription
requestDeleteProfileRequest

The request object containing all of the parameters for the API call.

deleteProfile(ProfileName name)

public final void deleteProfile(ProfileName name)

Deletes the specified profile. Prerequisite: The profile has no associated applications or assignments associated.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   ProfileName name = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
   profileServiceClient.deleteProfile(name);
 }
 
Parameter
NameDescription
nameProfileName

Required. Resource name of the profile to be deleted.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". For example, "projects/foo/tenants/bar/profiles/baz".

deleteProfile(String name)

public final void deleteProfile(String name)

Deletes the specified profile. Prerequisite: The profile has no associated applications or assignments associated.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   String name = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString();
   profileServiceClient.deleteProfile(name);
 }
 
Parameter
NameDescription
nameString

Required. Resource name of the profile to be deleted.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". For example, "projects/foo/tenants/bar/profiles/baz".

deleteProfileCallable()

public final UnaryCallable<DeleteProfileRequest,Empty> deleteProfileCallable()

Deletes the specified profile. Prerequisite: The profile has no associated applications or assignments associated.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   DeleteProfileRequest request =
       DeleteProfileRequest.newBuilder()
           .setName(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .build();
   ApiFuture<Empty> future = profileServiceClient.deleteProfileCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteProfileRequest,Empty>

getProfile(GetProfileRequest request)

public final Profile getProfile(GetProfileRequest request)

Gets the specified profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   GetProfileRequest request =
       GetProfileRequest.newBuilder()
           .setName(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .build();
   Profile response = profileServiceClient.getProfile(request);
 }
 
Parameter
NameDescription
requestGetProfileRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Profile

getProfile(ProfileName name)

public final Profile getProfile(ProfileName name)

Gets the specified profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   ProfileName name = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
   Profile response = profileServiceClient.getProfile(name);
 }
 
Parameter
NameDescription
nameProfileName

Required. Resource name of the profile to get.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". For example, "projects/foo/tenants/bar/profiles/baz".

Returns
TypeDescription
Profile

getProfile(String name)

public final Profile getProfile(String name)

Gets the specified profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   String name = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString();
   Profile response = profileServiceClient.getProfile(name);
 }
 
Parameter
NameDescription
nameString

Required. Resource name of the profile to get.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". For example, "projects/foo/tenants/bar/profiles/baz".

Returns
TypeDescription
Profile

getProfileCallable()

public final UnaryCallable<GetProfileRequest,Profile> getProfileCallable()

Gets the specified profile.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   GetProfileRequest request =
       GetProfileRequest.newBuilder()
           .setName(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .build();
   ApiFuture<Profile> future = profileServiceClient.getProfileCallable().futureCall(request);
   // Do something.
   Profile response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetProfileRequest,Profile>

getSettings()

public final ProfileServiceSettings getSettings()
Returns
TypeDescription
ProfileServiceSettings

getStub()

public ProfileServiceStub getStub()
Returns
TypeDescription
ProfileServiceStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listProfiles(ListProfilesRequest request)

public final ProfileServiceClient.ListProfilesPagedResponse listProfiles(ListProfilesRequest request)

Lists profiles by filter. The order is unspecified.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   ListProfilesRequest request =
       ListProfilesRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setFilter("filter-1274492040")
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   for (Profile element : profileServiceClient.listProfiles(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListProfilesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ProfileServiceClient.ListProfilesPagedResponse

listProfiles(TenantName parent)

public final ProfileServiceClient.ListProfilesPagedResponse listProfiles(TenantName parent)

Lists profiles by filter. The order is unspecified.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
   for (Profile element : profileServiceClient.listProfiles(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentTenantName

Required. The resource name of the tenant under which the profile is created.

The format is "projects/{project_id}/tenants/{tenant_id}". For example, "projects/foo/tenants/bar".

Returns
TypeDescription
ProfileServiceClient.ListProfilesPagedResponse

listProfiles(String parent)

public final ProfileServiceClient.ListProfilesPagedResponse listProfiles(String parent)

Lists profiles by filter. The order is unspecified.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   String parent = TenantName.of("[PROJECT]", "[TENANT]").toString();
   for (Profile element : profileServiceClient.listProfiles(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The resource name of the tenant under which the profile is created.

The format is "projects/{project_id}/tenants/{tenant_id}". For example, "projects/foo/tenants/bar".

Returns
TypeDescription
ProfileServiceClient.ListProfilesPagedResponse

listProfilesCallable()

public final UnaryCallable<ListProfilesRequest,ListProfilesResponse> listProfilesCallable()

Lists profiles by filter. The order is unspecified.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   ListProfilesRequest request =
       ListProfilesRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setFilter("filter-1274492040")
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   while (true) {
     ListProfilesResponse response = profileServiceClient.listProfilesCallable().call(request);
     for (Profile element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListProfilesRequest,ListProfilesResponse>

listProfilesPagedCallable()

public final UnaryCallable<ListProfilesRequest,ProfileServiceClient.ListProfilesPagedResponse> listProfilesPagedCallable()

Lists profiles by filter. The order is unspecified.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   ListProfilesRequest request =
       ListProfilesRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setFilter("filter-1274492040")
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Profile> future =
       profileServiceClient.listProfilesPagedCallable().futureCall(request);
   // Do something.
   for (Profile element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListProfilesRequest,ListProfilesPagedResponse>

searchProfiles(SearchProfilesRequest request)

public final ProfileServiceClient.SearchProfilesPagedResponse searchProfiles(SearchProfilesRequest request)

Searches for profiles within a tenant.

For example, search by raw queries "software engineer in Mountain View" or search by structured filters (location filter, education filter, etc.).

See SearchProfilesRequest for more information.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   SearchProfilesRequest request =
       SearchProfilesRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setRequestMetadata(RequestMetadata.newBuilder().build())
           .setProfileQuery(ProfileQuery.newBuilder().build())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setOffset(-1019779949)
           .setDisableSpellCheck(true)
           .setOrderBy("orderBy-1207110587")
           .setCaseSensitiveSort(true)
           .addAllHistogramQueries(new ArrayList
Parameter
NameDescription
requestSearchProfilesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ProfileServiceClient.SearchProfilesPagedResponse

searchProfilesCallable()

public final UnaryCallable<SearchProfilesRequest,SearchProfilesResponse> searchProfilesCallable()

Searches for profiles within a tenant.

For example, search by raw queries "software engineer in Mountain View" or search by structured filters (location filter, education filter, etc.).

See SearchProfilesRequest for more information.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   SearchProfilesRequest request =
       SearchProfilesRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setRequestMetadata(RequestMetadata.newBuilder().build())
           .setProfileQuery(ProfileQuery.newBuilder().build())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setOffset(-1019779949)
           .setDisableSpellCheck(true)
           .setOrderBy("orderBy-1207110587")
           .setCaseSensitiveSort(true)
           .addAllHistogramQueries(new ArrayList
Returns
TypeDescription
UnaryCallable<SearchProfilesRequest,SearchProfilesResponse>

searchProfilesPagedCallable()

public final UnaryCallable<SearchProfilesRequest,ProfileServiceClient.SearchProfilesPagedResponse> searchProfilesPagedCallable()

Searches for profiles within a tenant.

For example, search by raw queries "software engineer in Mountain View" or search by structured filters (location filter, education filter, etc.).

See SearchProfilesRequest for more information.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   SearchProfilesRequest request =
       SearchProfilesRequest.newBuilder()
           .setParent(TenantName.of("[PROJECT]", "[TENANT]").toString())
           .setRequestMetadata(RequestMetadata.newBuilder().build())
           .setProfileQuery(ProfileQuery.newBuilder().build())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setOffset(-1019779949)
           .setDisableSpellCheck(true)
           .setOrderBy("orderBy-1207110587")
           .setCaseSensitiveSort(true)
           .addAllHistogramQueries(new ArrayList
Returns
TypeDescription
UnaryCallable<SearchProfilesRequest,SearchProfilesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateProfile(Profile profile)

public final Profile updateProfile(Profile profile)

Updates the specified profile and returns the updated result.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   Profile profile = Profile.newBuilder().build();
   Profile response = profileServiceClient.updateProfile(profile);
 }
 
Parameter
NameDescription
profileProfile

Required. Profile to be updated.

Returns
TypeDescription
Profile

updateProfile(UpdateProfileRequest request)

public final Profile updateProfile(UpdateProfileRequest request)

Updates the specified profile and returns the updated result.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   UpdateProfileRequest request =
       UpdateProfileRequest.newBuilder()
           .setProfile(Profile.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Profile response = profileServiceClient.updateProfile(request);
 }
 
Parameter
NameDescription
requestUpdateProfileRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Profile

updateProfileCallable()

public final UnaryCallable<UpdateProfileRequest,Profile> updateProfileCallable()

Updates the specified profile and returns the updated result.

Sample code:


 try (ProfileServiceClient profileServiceClient = ProfileServiceClient.create()) {
   UpdateProfileRequest request =
       UpdateProfileRequest.newBuilder()
           .setProfile(Profile.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Profile> future = profileServiceClient.updateProfileCallable().futureCall(request);
   // Do something.
   Profile response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateProfileRequest,Profile>