use of com.google.cloud.talent.v4.Tenant in project java-talent by googleapis.
the class JobSearchCreateClientEvent method createClientEvent.
// Creates a client event.
public static void createClientEvent(String projectId, String tenantId, String requestId, String eventId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
TenantName parent = TenantName.of(projectId, tenantId);
// The timestamp of the event as seconds of UTC time since Unix epoch
// For more information on how to create google.protobuf.Timestamps
// See:
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
long seconds = 3L;
Timestamp createTime = Timestamp.newBuilder().setSeconds(seconds).build();
// The type of event attributed to the behavior of the end user
JobEvent.JobEventType type = JobEvent.JobEventType.VIEW;
// List of job names associated with this event
String jobsElement = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
String jobsElement2 = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
List<String> jobs = Arrays.asList(jobsElement, jobsElement2);
JobEvent jobEvent = JobEvent.newBuilder().setType(type).addAllJobs(jobs).build();
ClientEvent clientEvent = ClientEvent.newBuilder().setRequestId(requestId).setEventId(eventId).setCreateTime(createTime).setJobEvent(jobEvent).build();
CreateClientEventRequest request = CreateClientEventRequest.newBuilder().setParent(parent.toString()).setClientEvent(clientEvent).build();
ClientEvent response = eventServiceClient.createClientEvent(request);
System.out.println("Created client event. ");
System.out.println(response.toString());
}
}
use of com.google.cloud.talent.v4.Tenant in project java-talent by googleapis.
the class JobSearchCreateTenant method createTenant.
// Create Tenant for scoping resources, e.g. companies and jobs.
public static void createTenant(String projectId, String externalId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build();
CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(parent.toString()).setTenant(tenant).build();
Tenant response = tenantServiceClient.createTenant(request);
System.out.println("Created Tenant");
System.out.format("Name: %s%n", response.getName());
System.out.format("External ID: %s%n", response.getExternalId());
}
}
use of com.google.cloud.talent.v4.Tenant in project java-talent by googleapis.
the class JobSearchGetTenant method getTenant.
// Get Tenant by name.
public static void getTenant(String projectId, String tenantId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of(projectId, tenantId);
GetTenantRequest request = GetTenantRequest.newBuilder().setName(name.toString()).build();
Tenant response = tenantServiceClient.getTenant(request);
System.out.format("Name: %s%n", response.getName());
System.out.format("External ID: %s%n", response.getExternalId());
}
}
use of com.google.cloud.talent.v4.Tenant in project openstack4j by ContainX.
the class KeystoneTests method testAuthorizationFailure.
public void testAuthorizationFailure() throws IOException {
// First we simulate a 401 Authorization error
respondWith(401);
// The retry logic should re-authenticate and would be expecting the
// Access object
respondWith(JSON_ACCESS);
// The retry logic would then run the user lists expecting the proper
// result
respondWith(JSON_USERS);
assertEquals(osv2.identity().users().list().size(), 8);
// Positive test to make sure we are back in sync
respondWith(JSON_TENANT);
Tenant t = osv2.identity().tenants().get("b80f8d4e28b74188858b654cb1fccf7d");
assertEquals(t.getName(), "admin");
}
use of com.google.cloud.talent.v4.Tenant in project openstack4j by ContainX.
the class KeystoneTests method testTenants.
/**
* Tests tenant based operations
*
* @throws Exception
*/
public void testTenants() throws Exception {
respondWith(JSON_TENANTS);
List<? extends Tenant> tenants = osv2().identity().tenants().list();
assertEquals(tenants.size(), 3);
respondWith(JSON_TENANT);
Tenant t = osv2().identity().tenants().get("b80f8d4e28b74188858b654cb1fccf7d");
assertEquals(t.getName(), "admin");
}
Aggregations