use of com.google.api.services.storagetransfer.v1.model.ListOperationsResponse in project java-docs-samples by GoogleCloudPlatform.
the class CheckTransferJobApiary method checkTransferJob.
// Performs a list operation to check the status of a job
public static void checkTransferJob(String projectId, String jobName) throws IOException {
// Your Google Cloud Project ID
// String projectId = "your-project-id";
// The name of the job to check
// String jobName = "my-job-name";
// Create a Transfer Service client
GoogleCredentials credential = GoogleCredentials.getApplicationDefault();
if (credential.createScopedRequired()) {
credential = credential.createScoped(StoragetransferScopes.all());
}
Storagetransfer storageTransfer = new Storagetransfer.Builder(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory(), new HttpCredentialsAdapter(credential)).build();
// Filter for operations with jobName
ListOperationsResponse response = storageTransfer.transferOperations().list("transferOperations", projectId).setFilter("{\"project_id\": \"" + projectId + "\", \"job_names\": [\"" + jobName + "\"] }").execute();
System.out.println("List operation returned response:");
System.out.println(response.toPrettyString());
}
use of com.google.api.services.storagetransfer.v1.model.ListOperationsResponse in project java-docs-samples by GoogleCloudPlatform.
the class RequestChecker method main.
/**
* Output the returned list of TransferOperations.
*
* @param args
* arguments from the command line
*/
public static void main(String[] args) {
try {
ListOperationsResponse resp = checkTransfer(TransferClientCreator.createStorageTransferClient(), PROJECT_ID, JOB_NAME);
LOG.info("Result of transferOperations/list: " + resp.toPrettyString());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations