Search in sources :

Example 1 with ListOperationsResponse

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());
}
Also used : HttpCredentialsAdapter(com.google.auth.http.HttpCredentialsAdapter) ListOperationsResponse(com.google.api.services.storagetransfer.v1.model.ListOperationsResponse) GoogleCredentials(com.google.auth.oauth2.GoogleCredentials) Storagetransfer(com.google.api.services.storagetransfer.v1.Storagetransfer)

Example 2 with ListOperationsResponse

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();
    }
}
Also used : ListOperationsResponse(com.google.api.services.storagetransfer.v1.model.ListOperationsResponse) IOException(java.io.IOException)

Aggregations

ListOperationsResponse (com.google.api.services.storagetransfer.v1.model.ListOperationsResponse)2 Storagetransfer (com.google.api.services.storagetransfer.v1.Storagetransfer)1 HttpCredentialsAdapter (com.google.auth.http.HttpCredentialsAdapter)1 GoogleCredentials (com.google.auth.oauth2.GoogleCredentials)1 IOException (java.io.IOException)1