io.camunda.connector.gdrive.GoogleDriveClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of connector-google-drive Show documentation
Show all versions of connector-google-drive Show documentation
Camunda Google Drive Connector
The newest version!
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. Licensed under a proprietary license.
* See the License.txt file for more information. You may not use this file
* except in compliance with the proprietary license.
*/
package io.camunda.connector.gdrive;
import com.google.api.services.docs.v1.Docs;
import com.google.api.services.docs.v1.model.BatchUpdateDocumentRequest;
import com.google.api.services.docs.v1.model.BatchUpdateDocumentResponse;
import com.google.api.services.docs.v1.model.Request;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.File;
import java.io.IOException;
import java.util.List;
public class GoogleDriveClient {
private final Drive driveService;
private final Docs docsService;
public GoogleDriveClient(final Drive driveService, final Docs docsService) {
this.driveService = driveService;
this.docsService = docsService;
}
public File createWithMetadata(final File fileMetadata) {
try {
return driveService.files().create(fileMetadata).execute();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public File createWithTemplate(final File fileMetaData, final String templateId) {
try {
return driveService.files().copy(templateId, fileMetaData).execute();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public BatchUpdateDocumentResponse updateDocument(
final String fileId, final List requests) {
BatchUpdateDocumentRequest body = new BatchUpdateDocumentRequest().setRequests(requests);
try {
return docsService.documents().batchUpdate(fileId, body).execute();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}