Skip to content
Draft
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
63 changes: 17 additions & 46 deletions packages/api-v4/src/object-storage/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ import type {
*
* Get one Object Storage Bucket.
*/
export const getBucket = (clusterId: string, bucketName: string) =>
export const getBucket = (regionId: string, bucketName: string) =>
Request<ObjectStorageBucket>(
setMethod('GET'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}`,
),
);
Expand Down Expand Up @@ -84,7 +84,7 @@ export const getBucketsInRegion = (
*
* Creates a new Bucket on your account.
*
* @param data { object } The label and clusterId of the new Bucket.
* @param data { object } The label and region of the new Bucket.
*
*/
export const createBucket = (data: CreateObjectStorageBucketPayload) =>
Expand All @@ -102,42 +102,13 @@ export const createBucket = (data: CreateObjectStorageBucketPayload) =>
* NOTE: Attempting to delete a non-empty bucket will result in an error.
*/
export const deleteBucket = ({
cluster,
regionId,
label,
}: DeleteObjectStorageBucketPayload) =>
Request<ObjectStorageBucket>(
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
cluster,
)}/${encodeURIComponent(label)}`,
),
setMethod('DELETE'),
);

/**
* deleteBucketWithRegion
*
* Removes a Bucket from your account with region.
*
* NOTE: Attempting to delete a non-empty bucket will result in an error.
*/
/*
@TODO OBJ Multicluster: deleteBucketWithRegion is a function,
once feature is rolled out we replace it with existing deleteBucket
by updating it with region instead of cluster.
*/

export const deleteBucketWithRegion = ({
region,
label,
}: {
label: string;
region: string;
}) =>
Request<ObjectStorageBucket>(
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
region,
regionId,
)}/${encodeURIComponent(label)}`,
),
setMethod('DELETE'),
Expand All @@ -147,7 +118,7 @@ export const deleteBucketWithRegion = ({
* Returns a list of Objects in a given Bucket.
*/
export const getObjectList = ({
clusterId,
regionId,
bucket: bucketName,
params,
}: GetObjectStorageObjectListPayload) =>
Expand All @@ -156,7 +127,7 @@ export const getObjectList = ({
setParams(params),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/object-list`,
),
);
Expand All @@ -165,7 +136,7 @@ export const getObjectList = ({
* uploadSSLCert
*/
export const uploadSSLCert = (
clusterId: string,
regionId: string,
bucketName: string,
data: CreateObjectStorageBucketSSLPayload,
) =>
Expand All @@ -174,7 +145,7 @@ export const uploadSSLCert = (
setData(data, UploadCertificateSchema),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/ssl`,
),
);
Expand All @@ -185,12 +156,12 @@ export const uploadSSLCert = (
* Returns { ssl: true } if there is an SSL certificate available for
* the specified bucket, { ssl: false } otherwise.
*/
export const getSSLCert = (clusterId: string, bucketName: string) =>
export const getSSLCert = (regionId: string, bucketName: string) =>
Request<ObjectStorageBucketSSL>(
setMethod('GET'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/ssl`,
),
);
Expand All @@ -202,12 +173,12 @@ export const getSSLCert = (clusterId: string, bucketName: string) =>
* removed automatically when a bucket is deleted; this endpoint is only
* for removing certs without altering the bucket.
*/
export const deleteSSLCert = (clusterId: string, bucketName: string) =>
export const deleteSSLCert = (regionId: string, bucketName: string) =>
Request<{}>(
setMethod('DELETE'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/ssl`,
),
);
Expand All @@ -217,12 +188,12 @@ export const deleteSSLCert = (clusterId: string, bucketName: string) =>
*
* Returns access information (ACL, CORS) for a given Bucket.
*/
export const getBucketAccess = (clusterId: string, bucketName: string) =>
export const getBucketAccess = (regionId: string, bucketName: string) =>
Request<ObjectStorageBucketAccess>(
setMethod('GET'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/access`,
),
);
Expand All @@ -233,15 +204,15 @@ export const getBucketAccess = (clusterId: string, bucketName: string) =>
* Updates access information (ACL, CORS) for a given Bucket.
*/
export const updateBucketAccess = (
clusterId: string,
regionId: string,
bucketName: string,
params: UpdateObjectStorageBucketAccessPayload,
) =>
Request<{}>(
setMethod('PUT'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/access`,
),
setData(params, UpdateBucketAccessSchema),
Expand Down
18 changes: 0 additions & 18 deletions packages/api-v4/src/object-storage/clusters.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/api-v4/src/object-storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export * from './account';

export * from './buckets';

export * from './clusters';

export * from './objects';

export * from './objectStorageKeys';
Expand Down
16 changes: 8 additions & 8 deletions packages/api-v4/src/object-storage/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type {
* HTTP method in your request body's method parameter.
*/
export const getObjectURL = (
clusterId: string,
bucketName: string,
regionId: string,
bucket: string,
name: string,
method: 'DELETE' | 'GET' | 'POST' | 'PUT',
options?: CreateObjectStorageObjectURLPayload,
Expand All @@ -25,8 +25,8 @@ export const getObjectURL = (
setMethod('POST'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
)}/${encodeURIComponent(bucketName)}/object-url`,
regionId,
)}/${encodeURIComponent(bucket)}/object-url`,
),
setData({ name, method, ...options }),
);
Expand All @@ -38,15 +38,15 @@ export const getObjectURL = (
* Gets the ACL for a given Object.
*/
export const getObjectACL = ({
clusterId,
regionId,
bucket,
params,
}: GetObjectStorageACLPayload) =>
Request<ObjectStorageObjectACL>(
setMethod('GET'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucket)}/object-acl?name=${encodeURIComponent(
params.name,
)}`,
Expand All @@ -60,7 +60,7 @@ export const getObjectACL = ({
* Updates the ACL for a given Object.
*/
export const updateObjectACL = (
clusterId: string,
regionId: string,
bucketName: string,
name: string,
acl: Omit<ACLType, 'custom'>,
Expand All @@ -69,7 +69,7 @@ export const updateObjectACL = (
setMethod('PUT'),
setURL(
`${API_ROOT}/object-storage/buckets/${encodeURIComponent(
clusterId,
regionId,
)}/${encodeURIComponent(bucketName)}/object-acl`,
),
setData({ acl, name }),
Expand Down
19 changes: 5 additions & 14 deletions packages/api-v4/src/object-storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
bucket_name: string;
cluster: string;
permissions: ObjectStorageKeyBucketAccessPermissions;
region?: string; // @TODO OBJ Multicluster: Remove optional indicator when API changes get released to prod
region: string;
}

export interface CreateObjectStorageKeyPayload {
Expand All @@ -71,31 +71,22 @@

export interface CreateObjectStorageBucketPayload {
acl?: 'authenticated-read' | 'private' | 'public-read' | 'public-read-write';
cluster?: string;
cors_enabled?: boolean;
/**
* To explicitly create a bucket on a specific endpoint type.
*/
endpoint_type?: ObjectStorageEndpointTypes;
label: string;
region?: string;
region: string;
/**
* Used to create a bucket on a specific already-assigned S3 endpoint.
*/
s3_endpoint?: string;
/*
@TODO OBJ Multicluster: 'region' will become required, and the 'cluster' field will be deprecated
once the feature is fully rolled out in production as part of the process of cleaning up the 'objMultiCluster'
feature flag.

Until then, the API will accept either cluster or region, or both (provided they are the same value).
The payload requires at least one of them though, which will be enforced via validation.
*/
}

export interface DeleteObjectStorageBucketPayload {
cluster: string;
regionId: string;
label: string;

Check failure on line 89 in packages/api-v4/src/object-storage/types.ts

View workflow job for this annotation

GitHub Actions / lint (@linode/api-v4)

Expected "label" to come before "regionId"
}

export interface ObjectStorageBucket {
Expand Down Expand Up @@ -168,8 +159,8 @@

export interface GetObjectStorageObjectListPayload {
bucket: string;
clusterId: string;
regionId: string;
params?: ObjectStorageObjectListParams;

Check failure on line 163 in packages/api-v4/src/object-storage/types.ts

View workflow job for this annotation

GitHub Actions / lint (@linode/api-v4)

Expected "params" to come before "regionId"
}

interface ObjectStorageObjectListParams {
Expand Down Expand Up @@ -202,8 +193,8 @@

export interface GetObjectStorageACLPayload {
bucket: string;
clusterId: string;
regionId: string;
params: {

Check failure on line 197 in packages/api-v4/src/object-storage/types.ts

View workflow job for this annotation

GitHub Actions / lint (@linode/api-v4)

Expected "params" to come before "regionId"
name: string;
};
}
Expand Down
2 changes: 0 additions & 2 deletions packages/manager/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { configureMultiReporters } from './cypress/support/plugins/configure-mul
import { discardPassedTestRecordings } from './cypress/support/plugins/discard-passed-test-recordings';
import { featureFlagOverrides } from './cypress/support/plugins/feature-flag-override';
import { fetchAccount } from './cypress/support/plugins/fetch-account';
import { fetchLinodeClusters } from './cypress/support/plugins/fetch-linode-clusters';
import { fetchLinodeImages } from './cypress/support/plugins/fetch-linode-images';
import { fetchLinodeRegions } from './cypress/support/plugins/fetch-linode-regions';
import { generateTestWeights } from './cypress/support/plugins/generate-weights';
Expand Down Expand Up @@ -102,7 +101,6 @@ export default defineConfig({
discardPassedTestRecordings,
fetchAccount,
fetchLinodeRegions,
fetchLinodeClusters,
fetchLinodeImages,
resetUserPreferences,
regionOverrideCheck,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {
mockCreateBucket,
mockDeleteBucket,
mockDeleteBucketObject,
mockCreateObjectUrl,

Check failure on line 11 in packages/manager/cypress/e2e/core/objectStorage/object-storage.smoke.spec.ts

View workflow job for this annotation

GitHub Actions / ESLint Review (manager)

[eslint] reported by reviewdog 🐶 Expected "mockCreateObjectUrl" to come before "mockDeleteBucket". Raw Output: {"ruleId":"perfectionist/sort-named-imports","severity":2,"message":"Expected \"mockCreateObjectUrl\" to come before \"mockDeleteBucket\".","line":11,"column":3,"nodeType":"ImportSpecifier","messageId":"unexpectedNamedImportsOrder","endLine":11,"endColumn":22,"fix":{"range":[266,305],"text":"mockCreateObjectUrl,
mockDeleteBucketObjectS3,
mockGetBucketObjects,
mockGetBuckets,
Expand Down Expand Up @@ -142,7 +142,7 @@
bucketContents.forEach((bucketFile) => {
const filename = bucketFile.split('/')[1];

mockDeleteBucketObject(bucketLabel, bucketCluster, filename).as(
mockCreateObjectUrl(bucketLabel, bucketCluster, filename).as(
'deleteBucketObject'
);
mockDeleteBucketObjectS3(bucketLabel, bucketCluster, filename).as(
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/cypress/support/api/objectStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const deleteAllTestBucketObjects = async (
// @TODO Improve object retrieval to account for pagination for buckets with many objects.
const storageObjects = await getObjectList({
bucket: bucketLabel,
clusterId,
regionId: clusterId,
});
const storageObjectDeletePromises = storageObjects.data.map(
async (storageObject: ObjectStorageObject) => {
Expand Down Expand Up @@ -104,7 +104,7 @@ export const deleteAllTestBuckets = async () => {
bucket.label
);
return deleteBucket({
cluster: bucket.region || bucket.cluster,
regionId: bucket.region || bucket.cluster,
label: bucket.label,
});
}
Expand Down
Loading
Loading