@webda/gcp 2.0.0-beta.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,30 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
6
  };
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const storage_1 = require("@google-cloud/storage");
19
- const mocha_1 = require("@testdeck/mocha");
20
- const binary_spec_1 = require("@webda/core/lib/services/binary.spec");
21
- const assert = require("assert");
22
- const path = require("path");
23
- const sinon = require("sinon");
7
+ import { Storage as GCS } from "@google-cloud/storage";
8
+ import { suite, test } from "@testdeck/mocha";
9
+ import { BinaryTest } from "@webda/core/lib/services/binary.spec.js";
10
+ import * as assert from "assert";
11
+ import * as path from "path";
12
+ import * as sinon from "sinon";
13
+ import { getCommonJS } from "@webda/core";
14
+ const { __dirname } = getCommonJS(import.meta.url);
24
15
  class MockFile {
25
16
  constructor(path) { }
26
- delete() {
27
- return __awaiter(this, void 0, void 0, function* () { });
28
- }
29
- getFiles() {
30
- return __awaiter(this, void 0, void 0, function* () { });
31
- }
32
- exists() {
33
- return __awaiter(this, void 0, void 0, function* () { });
34
- }
35
- save() {
36
- return __awaiter(this, void 0, void 0, function* () { });
37
- }
38
- setMetadata() {
39
- return __awaiter(this, void 0, void 0, function* () { });
40
- }
41
- createWriteStream() {
42
- return __awaiter(this, void 0, void 0, function* () { });
43
- }
44
- getSignedUrl() {
45
- return __awaiter(this, void 0, void 0, function* () { });
46
- }
47
- publicUrl() {
48
- return __awaiter(this, void 0, void 0, function* () { });
49
- }
50
- getMetadata() {
51
- return __awaiter(this, void 0, void 0, function* () { });
52
- }
53
- createReadStream() {
54
- return __awaiter(this, void 0, void 0, function* () { });
55
- }
56
- move() {
57
- return __awaiter(this, void 0, void 0, function* () { });
58
- }
17
+ async delete() { }
18
+ async getFiles() { }
19
+ async exists() { }
20
+ async save() { }
21
+ async setMetadata() { }
22
+ async createWriteStream() { }
23
+ async getSignedUrl() { }
24
+ async publicUrl() { }
25
+ async getMetadata() { }
26
+ async createReadStream() { }
27
+ async move() { }
59
28
  }
60
29
  class MockBucket {
61
30
  file(path) {
@@ -63,151 +32,126 @@ class MockBucket {
63
32
  }
64
33
  }
65
34
  const BUCKET = "webda-dev";
66
- let StorageTest = class StorageTest extends binary_spec_1.BinaryTest {
67
- before() {
68
- const _super = Object.create(null, {
69
- before: { get: () => super.before }
70
- });
71
- return __awaiter(this, void 0, void 0, function* () {
72
- this.buildWebda();
73
- yield this.install();
74
- yield _super.before.call(this);
75
- this.prefix = this.getBinary().getWebda().getUuid();
76
- this.getBinary().getParameters().prefix = this.prefix;
77
- // Prepare for Mocked Version
78
- if (!process.env.NO_MOCK && false) {
79
- sinon.stub(this.getBinary(), "getStorageBucket").callsFake(() => {
80
- return new MockBucket();
81
- });
82
- }
83
- });
84
- }
85
- after() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- yield this.cleanData();
88
- });
89
- }
90
- install() {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- var storage = new storage_1.Storage();
93
- try {
94
- let [metadata] = yield storage.bucket(BUCKET).getMetadata();
95
- if (!metadata) {
96
- yield storage.createBucket(BUCKET, { location: "US-WEST2", storageClass: "COLDLINE" });
97
- yield storage.bucket(BUCKET).getMetadata();
98
- }
99
- //this.webda.log("INFO", `Google cloud storage bucket '${BUCKET}' exists`);
100
- }
101
- catch (e) {
102
- this.webda.log("ERROR", `Google cloud storage error (${e.message})`);
103
- }
104
- });
105
- }
106
- cleanData() {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- var storage = new storage_1.Storage();
109
- const [files] = yield storage.bucket(BUCKET).getFiles({
110
- prefix: this.prefix,
35
+ let StorageTest = class StorageTest extends BinaryTest {
36
+ async before() {
37
+ this.buildWebda();
38
+ await this.install();
39
+ await super.before();
40
+ this.prefix = this.getBinary().getWebda().getUuid();
41
+ this.getBinary().getParameters().prefix = this.prefix;
42
+ // Prepare for Mocked Version
43
+ if (!process.env.NO_MOCK && false) {
44
+ sinon.stub(this.getBinary(), "getStorageBucket").callsFake(() => {
45
+ return new MockBucket();
111
46
  });
112
- for (let file of files) {
113
- yield file.delete();
47
+ }
48
+ }
49
+ async after() {
50
+ await this.cleanData();
51
+ }
52
+ async install() {
53
+ var storage = new GCS();
54
+ try {
55
+ let [metadata] = await storage.bucket(BUCKET).getMetadata();
56
+ if (!metadata) {
57
+ await storage.createBucket(BUCKET, { location: "US-WEST2", storageClass: "COLDLINE" });
58
+ await storage.bucket(BUCKET).getMetadata();
114
59
  }
60
+ //this.webda.log("INFO", `Google cloud storage bucket '${BUCKET}' exists`);
61
+ }
62
+ catch (e) {
63
+ this.webda.log("ERROR", `Google cloud storage error (${e.message})`);
64
+ }
65
+ }
66
+ async cleanData() {
67
+ var storage = new GCS();
68
+ const [files] = await storage.bucket(BUCKET).getFiles({
69
+ prefix: this.prefix,
115
70
  });
71
+ for (let file of files) {
72
+ await file.delete();
73
+ }
116
74
  }
117
75
  // Override getNotFound as exception is raised after
118
76
  // @test
119
77
  // async getNotFound() {}
120
- putObject() {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- const body = `RAW Body: ${new Date()}`;
123
- const name = `${this.prefix}/plop/test`;
124
- yield this.getBinary().putObject(name, Buffer.from(body), { meta1: "meta1" }, BUCKET);
125
- let getFile = this.getBinary().getStorageBucket().file(name);
126
- assert.deepStrictEqual((yield getFile.getMetadata())[0].metadata, { meta1: "meta1" });
127
- });
78
+ async putObject() {
79
+ const body = `RAW Body: ${new Date()}`;
80
+ const name = `${this.prefix}/plop/test`;
81
+ await this.getBinary().putObject(name, Buffer.from(body), { meta1: "meta1" }, BUCKET);
82
+ let getFile = this.getBinary().getStorageBucket().file(name);
83
+ assert.deepStrictEqual((await getFile.getMetadata())[0].metadata, { meta1: "meta1" });
128
84
  }
129
85
  // Override getNotFound as exception is raised after
130
- getNotFound() {
131
- return __awaiter(this, void 0, void 0, function* () { });
132
- }
133
- httpGetError() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- // GET is not through classic binary
136
- // Skip it
137
- });
138
- }
139
- redirectUrl() {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- let { user1, ctx } = yield this.setupDefault();
142
- // Making sure we are redirected on GET
143
- let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0`, {});
144
- yield executor.execute(ctx);
145
- assert.ok(ctx.getResponseHeaders().Location !== undefined);
146
- });
147
- }
148
- redirectUrlInfo() {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- let { user1, ctx } = yield this.setupDefault();
151
- // Making sure we are redirected on GET
152
- let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0/url`, {});
153
- yield executor.execute(ctx);
154
- assert.ok(ctx.getResponseHeaders().Location === undefined);
155
- assert.notStrictEqual(JSON.parse(ctx.getResponseBody()).Location, undefined);
156
- });
157
- }
158
- cascadeDelete() {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- let stubDelete = sinon.stub(this.getBinary(), "_cleanUsage").callsFake(() => {
161
- throw new Error();
162
- });
163
- try {
164
- // @ts-ignore
165
- yield this.getBinary().cascadeDelete({ hash: "pp" }, "pp");
166
- }
167
- finally {
168
- stubDelete.restore();
169
- }
170
- });
171
- }
172
- defaultGCS() {
173
- return __awaiter(this, void 0, void 0, function* () {
174
- let { user1, ctx } = yield this.setupDefault();
175
- // COV for double
176
- const binary = this.getBinary();
177
- const from = `${this.prefix}/rawAccess`;
178
- const to = `${this.prefix}/movedAccess`;
179
- yield binary.putObject(from, path.join(__dirname, "..", "..", "test", "Dockerfile.txt"));
180
- yield binary.moveObject({ key: from }, { key: to });
181
- assert.deepStrictEqual(binary.getSignedUrlHeaders(), {});
182
- const meta = yield binary.getMeta({ bucket: "webda-dev", key: to });
183
- assert.deepStrictEqual(meta, { size: 311, contentType: "text/plain" });
184
- assert.ok(/https:\/\/storage\.googleapis\.com\/webda-dev\/webda-dev/.exec(yield binary.getPublicUrl({ key: "webda-dev" })));
185
- yield binary.deleteObject({ key: to });
86
+ async getNotFound() { }
87
+ async httpGetError() {
88
+ // GET is not through classic binary
89
+ // Skip it
90
+ }
91
+ async redirectUrl() {
92
+ let { user1, ctx } = await this.setupDefault();
93
+ // Making sure we are redirected on GET
94
+ let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0`, {});
95
+ await executor.execute(ctx);
96
+ assert.ok(ctx.getResponseHeaders().Location !== undefined);
97
+ }
98
+ async redirectUrlInfo() {
99
+ let { user1, ctx } = await this.setupDefault();
100
+ // Making sure we are redirected on GET
101
+ let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0/url`, {});
102
+ await executor.execute(ctx);
103
+ assert.ok(ctx.getResponseHeaders().Location === undefined);
104
+ assert.notStrictEqual(JSON.parse(ctx.getResponseBody()).Location, undefined);
105
+ }
106
+ async cascadeDelete() {
107
+ let stubDelete = sinon.stub(this.getBinary(), "_cleanUsage").callsFake(() => {
108
+ throw new Error();
186
109
  });
110
+ try {
111
+ // @ts-ignore
112
+ await this.getBinary().cascadeDelete({ hash: "pp" }, "pp");
113
+ }
114
+ finally {
115
+ stubDelete.restore();
116
+ }
117
+ }
118
+ async defaultGCS() {
119
+ let { user1, ctx } = await this.setupDefault();
120
+ // COV for double
121
+ const binary = this.getBinary();
122
+ const from = `${this.prefix}/rawAccess`;
123
+ const to = `${this.prefix}/movedAccess`;
124
+ await binary.putObject(from, path.join(__dirname, "..", "..", "test", "Dockerfile.txt"));
125
+ await binary.moveObject({ key: from }, { key: to });
126
+ assert.deepStrictEqual(binary.getSignedUrlHeaders(), {});
127
+ const meta = await binary.getMeta({ bucket: "webda-dev", key: to });
128
+ assert.deepStrictEqual(meta, { size: 311, contentType: "text/plain" });
129
+ assert.ok(/https:\/\/storage\.googleapis\.com\/webda-dev\/webda-dev/.exec(await binary.getPublicUrl({ key: "webda-dev" })));
130
+ await binary.deleteObject({ key: to });
187
131
  }
188
132
  };
189
133
  __decorate([
190
- mocha_1.test
134
+ test
191
135
  ], StorageTest.prototype, "putObject", null);
192
136
  __decorate([
193
- mocha_1.test
137
+ test
194
138
  ], StorageTest.prototype, "getNotFound", null);
195
139
  __decorate([
196
- mocha_1.test
140
+ test
197
141
  ], StorageTest.prototype, "httpGetError", null);
198
142
  __decorate([
199
- mocha_1.test
143
+ test
200
144
  ], StorageTest.prototype, "redirectUrl", null);
201
145
  __decorate([
202
- mocha_1.test
146
+ test
203
147
  ], StorageTest.prototype, "redirectUrlInfo", null);
204
148
  __decorate([
205
- mocha_1.test
149
+ test
206
150
  ], StorageTest.prototype, "cascadeDelete", null);
207
151
  __decorate([
208
- mocha_1.test
152
+ test
209
153
  ], StorageTest.prototype, "defaultGCS", null);
210
154
  StorageTest = __decorate([
211
- mocha_1.suite
155
+ suite
212
156
  ], StorageTest);
213
157
  //# sourceMappingURL=storage.spec.js.map
@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AAC;QACzF,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,EAAE,EAAE,EAAE,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,EAAE,CACP,0DAA0D,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC,CACjH,CAAC;QACF,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AApEC;IADC,IAAI;4CAQJ;AAID;IADC,IAAI;8CACiB;AAGtB;IADC,IAAI;+CAIJ;AAGD;IADC,IAAI;8CAOJ;AAGD;IADC,IAAI;kDAQJ;AAGD;IADC,IAAI;gDAWJ;AAGD;IADC,IAAI;6CAgBJ;AApHG,WAAW;IADhB,KAAK;GACA,WAAW,CAqHhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webda/gcp",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0",
4
4
  "description": "Webda GCP Services implementation",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "pretest": "npm run build",
9
9
  "lint": "prettier --check src/**/*",
10
10
  "lint:fix": "prettier --write src/**/*",
11
- "test": "nyc mocha --recursive --exit --timeout=100000 -r ../../node_modules/ts-node/register src/**/*.spec.ts"
11
+ "test": "c8 mocha --recursive --exit --timeout=100000 src/**/*.spec.ts"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
@@ -32,11 +32,10 @@
32
32
  "dependencies": {
33
33
  "@google-cloud/firestore": "^5.0.2",
34
34
  "@google-cloud/pubsub": "^3.0.0",
35
- "@google-cloud/storage": "~6.0.1",
36
- "@webda/core": "^2.0.0-beta.3"
35
+ "@google-cloud/storage": "~6.1.0",
36
+ "@webda/core": "^2.0.0"
37
37
  },
38
- "nyc": {
39
- "extends": "@istanbuljs/nyc-config-typescript",
38
+ "c8": {
40
39
  "report-dir": "./reports",
41
40
  "reporter": [
42
41
  "html",
@@ -54,10 +53,14 @@
54
53
  },
55
54
  "devDependencies": {
56
55
  "@testdeck/mocha": "^0.2.0",
57
- "@types/node": "14.0.0",
58
- "@webda/async": "^2.0.0-beta.3",
59
- "@webda/shell": "^2.0.0-beta.3",
56
+ "@types/node": "14.6.0",
57
+ "@webda/async": "^2.0.0",
58
+ "@webda/shell": "^2.0.0",
60
59
  "sinon": "^14.0.0"
61
60
  },
62
- "gitHead": "f95827566d42d22c32aed524b74d0446fff66ed4"
61
+ "type": "module",
62
+ "engines": {
63
+ "node": ">=14.6.0"
64
+ },
65
+ "gitHead": "5764db57432f146c84b2e8f52cf49fb5ded3af29"
63
66
  }
package/webda.module.json CHANGED
@@ -9,79 +9,16 @@
9
9
  "models": {},
10
10
  "deployers": {},
11
11
  "schemas": {
12
- "webda/googlecloudstorage": {
12
+ "webda/googlecloudfirestore": {
13
13
  "type": "object",
14
14
  "properties": {
15
15
  "type": {
16
16
  "type": "string",
17
17
  "description": "Type of the service"
18
18
  },
19
- "map": {
20
- "type": "object",
21
- "additionalProperties": {
22
- "type": "array",
23
- "items": {
24
- "type": "string"
25
- }
26
- },
27
- "description": "Define the map to Object collection\n\nkey is a Store name the string[] represent all valids attributes to store files in"
28
- },
29
- "expose": {
30
- "type": "object",
31
- "properties": {
32
- "url": {
33
- "type": "string",
34
- "description": "URL to expose the service to"
35
- },
36
- "restrict": {
37
- "type": "object",
38
- "properties": {
39
- "get": {
40
- "type": "boolean",
41
- "description": "Restrict GET"
42
- },
43
- "create": {
44
- "type": "boolean",
45
- "description": "Restrict POST"
46
- },
47
- "delete": {
48
- "type": "boolean",
49
- "description": "Restrict DELETE"
50
- },
51
- "metadata": {
52
- "type": "boolean",
53
- "description": "Restrict update of metadata"
54
- }
55
- },
56
- "description": "Restrict some APIs"
57
- }
58
- },
59
- "required": [
60
- "url"
61
- ],
62
- "description": "Expose the service to http"
63
- },
64
- "prefix": {
65
- "type": "string"
66
- },
67
- "bucket": {
68
- "type": "string"
69
- }
70
- },
71
- "required": [
72
- "bucket",
73
- "map",
74
- "type"
75
- ],
76
- "$schema": "http://json-schema.org/draft-07/schema#",
77
- "title": "GoogleCloudStorage"
78
- },
79
- "webda/googlecloudfirestore": {
80
- "type": "object",
81
- "properties": {
82
- "type": {
19
+ "url": {
83
20
  "type": "string",
84
- "description": "Type of the service"
21
+ "description": "URL on which to serve the content"
85
22
  },
86
23
  "model": {
87
24
  "type": "string",
@@ -116,6 +53,10 @@
116
53
  "$ref": "#/definitions/FireStoreIndex"
117
54
  },
118
55
  "description": "To allow efficient query on several fields"
56
+ },
57
+ "openapi": {
58
+ "type": "object",
59
+ "additionalProperties": true
119
60
  }
120
61
  },
121
62
  "required": [
@@ -195,6 +136,10 @@
195
136
  "type": "string",
196
137
  "description": "Type of the service"
197
138
  },
139
+ "url": {
140
+ "type": "string",
141
+ "description": "URL on which to serve the content"
142
+ },
198
143
  "topic": {
199
144
  "type": "string",
200
145
  "description": "Topic to use on GCP"
@@ -202,6 +147,10 @@
202
147
  "subscriptionOptions": {
203
148
  "$ref": "#/definitions/CreateSubscriptionOptions",
204
149
  "description": "Subscription options to pass to GCP"
150
+ },
151
+ "openapi": {
152
+ "type": "object",
153
+ "additionalProperties": true
205
154
  }
206
155
  },
207
156
  "required": [
@@ -973,6 +922,10 @@
973
922
  "type": "string",
974
923
  "description": "Type of the service"
975
924
  },
925
+ "url": {
926
+ "type": "string",
927
+ "description": "URL on which to serve the content"
928
+ },
976
929
  "workerDelayer": {
977
930
  "type": "object",
978
931
  "properties": {
@@ -1012,6 +965,10 @@
1012
965
  "timeout": {
1013
966
  "type": "number",
1014
967
  "description": "Timeout when receiveMessage is used before returning empty result (in ms)\n\nIf not define then no timeout is applied and receiveMessage can hang forever"
968
+ },
969
+ "openapi": {
970
+ "type": "object",
971
+ "additionalProperties": true
1015
972
  }
1016
973
  },
1017
974
  "required": [
@@ -1023,6 +980,81 @@
1023
980
  "description": "GCPQueue Parameters",
1024
981
  "$schema": "http://json-schema.org/draft-07/schema#",
1025
982
  "title": "GoogleCloudQueue"
983
+ },
984
+ "webda/googlecloudstorage": {
985
+ "type": "object",
986
+ "properties": {
987
+ "type": {
988
+ "type": "string",
989
+ "description": "Type of the service"
990
+ },
991
+ "url": {
992
+ "type": "string",
993
+ "description": "URL on which to serve the content"
994
+ },
995
+ "map": {
996
+ "type": "object",
997
+ "additionalProperties": {
998
+ "type": "array",
999
+ "items": {
1000
+ "type": "string"
1001
+ }
1002
+ },
1003
+ "description": "Define the map to Object collection\n\nkey is a Store name the string[] represent all valids attributes to store files in"
1004
+ },
1005
+ "expose": {
1006
+ "type": "object",
1007
+ "properties": {
1008
+ "url": {
1009
+ "type": "string",
1010
+ "description": "URL to expose the service to"
1011
+ },
1012
+ "restrict": {
1013
+ "type": "object",
1014
+ "properties": {
1015
+ "get": {
1016
+ "type": "boolean",
1017
+ "description": "Restrict GET"
1018
+ },
1019
+ "create": {
1020
+ "type": "boolean",
1021
+ "description": "Restrict POST"
1022
+ },
1023
+ "delete": {
1024
+ "type": "boolean",
1025
+ "description": "Restrict DELETE"
1026
+ },
1027
+ "metadata": {
1028
+ "type": "boolean",
1029
+ "description": "Restrict update of metadata"
1030
+ }
1031
+ },
1032
+ "description": "Restrict some APIs"
1033
+ }
1034
+ },
1035
+ "required": [
1036
+ "url"
1037
+ ],
1038
+ "description": "Expose the service to http"
1039
+ },
1040
+ "prefix": {
1041
+ "type": "string"
1042
+ },
1043
+ "bucket": {
1044
+ "type": "string"
1045
+ },
1046
+ "openapi": {
1047
+ "type": "object",
1048
+ "additionalProperties": true
1049
+ }
1050
+ },
1051
+ "required": [
1052
+ "bucket",
1053
+ "map",
1054
+ "type"
1055
+ ],
1056
+ "$schema": "http://json-schema.org/draft-07/schema#",
1057
+ "title": "GoogleCloudStorage"
1026
1058
  }
1027
1059
  }
1028
1060
  }