Skip to content

Commit

Permalink
update storage.ts documentation, use storage transport in channel.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 committed May 16, 2024
1 parent 92eaf56 commit f86880e
Show file tree
Hide file tree
Showing 27 changed files with 913 additions and 1,182 deletions.
10 changes: 4 additions & 6 deletions conformance-test/conformanceCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as libraryMethods from './libraryMethods';
import {Bucket, File, HmacKey, Notification, Storage} from '../src/';
import * as uuid from 'uuid';
import * as assert from 'assert';
import {DecorateRequestOptions} from '../src/nodejs-common';
import fetch from 'node-fetch';

interface RetryCase {
Expand Down Expand Up @@ -122,19 +121,18 @@ export function executeScenario(testCase: RetryTestCase) {
notification = bucket.notification(`${TESTS_PREFIX}`);
await notification.create();

[hmacKey] = await storage.createHmacKey(
`${TESTS_PREFIX}@email.com`
);
hmacKey = await storage.createHmacKey(`${TESTS_PREFIX}@email.com`);

storage.interceptors.push({
//TODO: Interceptors
/* storage.interceptors.push({
request: requestConfig => {
requestConfig.headers = requestConfig.headers || {};
Object.assign(requestConfig.headers, {
'x-retry-test-id': creationResult.id,
});
return requestConfig as DecorateRequestOptions;
},
});
}); */
});

it(`${instructionNumber}`, async () => {
Expand Down
4 changes: 2 additions & 2 deletions conformance-test/libraryMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function combine(options: ConformanceTestOptions) {
}

export async function create(options: ConformanceTestOptions) {
const [bucketExists] = await options.bucket!.exists();
const bucketExists = await options.bucket!.exists();
if (bucketExists) {
await options.bucket!.deleteFiles();
await options.bucket!.delete({
Expand Down Expand Up @@ -795,7 +795,7 @@ export async function notificationGetMetadata(options: ConformanceTestOptions) {

export async function createBucket(options: ConformanceTestOptions) {
const bucket = options.storage!.bucket('test-creating-bucket');
const [exists] = await bucket.exists();
const exists = await bucket.exists();
if (exists) {
bucket.delete();
}
Expand Down
2 changes: 1 addition & 1 deletion internal-tooling/performanceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export async function performanceTestSetup(
ifGenerationMatch: 0,
},
});
if (!(await bucket.exists())[0]) {
if (!(await bucket.exists())) {
await bucket.create();
}
const transferManager = new TransferManager(bucket);
Expand Down
38 changes: 19 additions & 19 deletions src/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {
BodyResponseCallback,
DecorateRequestOptions,
BaseMetadata,
} from './nodejs-common/index.js';
import {BodyResponseCallback, BaseMetadata} from './nodejs-common/index.js';
import {promisifyAll} from '@google-cloud/promisify';
import {
StorageQueryParameters,
StorageRequestOptions,
} from './storage-transport.js';

export interface AclOptions {
pathPrefix: string;
request: (
reqOpts: DecorateRequestOptions,
reqOpts: StorageRequestOptions,
callback: BodyResponseCallback
) => void;
}
Expand Down Expand Up @@ -419,7 +419,7 @@ class Acl extends AclRoleAccessorMethods {
default!: Acl;
pathPrefix: string;
request_: (
reqOpts: DecorateRequestOptions,
reqOpts: StorageRequestOptions,
callback: BodyResponseCallback
) => void;

Expand Down Expand Up @@ -523,10 +523,10 @@ class Acl extends AclRoleAccessorMethods {
this.request(
{
method: 'POST',
uri: '',
qs: query,
url: '',
queryParameters: query as unknown as StorageQueryParameters,
maxRetries: 0, //explicitly set this value since this is a non-idempotent function
json: {
body: {
entity: options.entity,
role: options.role.toUpperCase(),
},
Expand Down Expand Up @@ -623,8 +623,8 @@ class Acl extends AclRoleAccessorMethods {
this.request(
{
method: 'DELETE',
uri: '/' + encodeURIComponent(options.entity),
qs: query,
url: '/' + encodeURIComponent(options.entity),
queryParameters: query as unknown as StorageQueryParameters,
},
(err, resp) => {
callback!(err, resp);
Expand Down Expand Up @@ -745,8 +745,8 @@ class Acl extends AclRoleAccessorMethods {

this.request(
{
uri: path,
qs: query,
url: path,
queryParameters: query as unknown as StorageQueryParameters,
},
(err, resp) => {
if (err) {
Expand Down Expand Up @@ -845,9 +845,9 @@ class Acl extends AclRoleAccessorMethods {
this.request(
{
method: 'PUT',
uri: '/' + encodeURIComponent(options.entity),
qs: query,
json: {
url: '/' + encodeURIComponent(options.entity),
queryParameters: query as unknown as StorageQueryParameters,
body: {
role: options.role.toUpperCase(),
},
},
Expand Down Expand Up @@ -894,10 +894,10 @@ class Acl extends AclRoleAccessorMethods {
* @param {function} callback Callback function.
*/
request(
reqOpts: DecorateRequestOptions,
reqOpts: StorageRequestOptions,
callback: BodyResponseCallback
): void {
reqOpts.uri = this.pathPrefix + reqOpts.uri;
reqOpts.url = this.pathPrefix + reqOpts.url;
this.request_(reqOpts, callback);
}
}
Expand Down

0 comments on commit f86880e

Please sign in to comment.