Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions lib/data/external/GCP/GcpService.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
const googleAuth = require('google-auto-auth');
const async = require('async');
const AWS = require('aws-sdk');
const stream = require('stream');
const { errors } = require('arsenal');
const Service = AWS.Service;

const GcpSigner = require('./GcpSigner');

/**
* genAuth - create a google authorizer for generating request tokens
* @param {object} authParams - params that contains the credentials for
* generating the authorizer
* @param {function} callback - callback function to call with the authorizer
* @return {undefined}
*/
function genAuth(authParams, callback) {
async.tryEach([
function authKeyFile(next) {
Expand All @@ -32,6 +40,12 @@ const GCP = Service.defineService('gcp', ['2017-11-01'], {
_jsonAuth: null,
_authParams: null,

/**
* getToken - generate a token for authorizing JSON API requests
* @param {function} callback - callback function to call with the
* generated token
* @return {undefined}
*/
getToken(callback) {
if (this._jsonAuth) {
return this._jsonAuth.getToken(callback);
Expand Down Expand Up @@ -69,12 +83,17 @@ const GCP = Service.defineService('gcp', ['2017-11-01'], {
return this.listObjects(params, callback);
},

// TO-DO: Implemented the following APIs
upload(params, options, callback) {
return callback(errors.NotImplemented
.customizeDescription('GCP: upload not implemented'));
// Object APIs
upload(params, callback) {
if (params.Body instanceof stream) {
return callback(errors.NotImplemented
.customizeDescription(
'GCP: Upload with stream body not implemented'));
}
return this.putObject(params, callback);
},

// TO-DO: Implement the following APIs
// Service API
listBuckets(params, callback) {
return callback(errors.NotImplemented
Expand Down Expand Up @@ -148,26 +167,6 @@ const GCP = Service.defineService('gcp', ['2017-11-01'], {
},

// Object APIs
headObject(params, callback) {
return callback(errors.NotImplemented
.customizeDescription('GCP: headObject not implemented'));
},

putObject(params, callback) {
return callback(errors.NotImplemented
.customizeDescription('GCP: putObject not implemented'));
},

getObject(params, callback) {
return callback(errors.NotImplemented
.customizeDescription('GCP: getObject not implemented'));
},

deleteObject(params, callback) {
return callback(errors.NotImplemented
.customizeDescription('GCP: deleteObject not implemented'));
},

deleteObjects(params, callback) {
return callback(errors.NotImplemented
.customizeDescription('GCP: deleteObjects not implemented'));
Expand Down
Loading