Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OBJ Group and Objects for MultiCluster Object Storage API Changes #426

Conversation

zliang-akamai
Copy link
Member

@zliang-akamai zliang-akamai commented Jun 20, 2024

📝 Description

This is to modify ObjectStorageGroup and object storage related SDK objects to adapt to the MultiCluster Object Storage API changes.

✔️ How to Test

Automated Testing

make testunit
make TEST_SUITE=object_storage testint

Manual Testing

import os

from linode_api4 import LinodeClient
from linode_api4.objects import ObjectStorageACL
from linode_api4.objects.object_storage import ObjectStorageKeyPermission

client = LinodeClient(os.getenv("LINODE_TOKEN"))

TEST_REGION="us-mia"
TEST_CLUSTER="us-mia-1"

bucket1 = client.object_storage.bucket_create(
    cluster_or_region=TEST_REGION,
    label="test-python-sdk-bucket",
    acl=ObjectStorageACL.PRIVATE,
    cors_enabled=False,
)

key1 = client.object_storage.keys_create(
    label="test-python-sdk-limited-key",
    bucket_access=client.object_storage.bucket_access(
        cluster_or_region=TEST_REGION,
        bucket_name=bucket1.label,
        permissions=ObjectStorageKeyPermission.READ_ONLY,
        use_region=True,
    ),
    regions=["us-mia"],
)

bucket1._api_get()
key1._api_get()

print("Created with a region:")
print(bucket1._raw_json)
print(key1._raw_json)

key1.delete()
bucket1.delete()

bucket2 = client.object_storage.bucket_create(
    cluster_or_region=TEST_CLUSTER,
    label="test-python-sdk-bucket",
    acl=ObjectStorageACL.PRIVATE,
    cors_enabled=False,
)

key2 = client.object_storage.keys_create(
    label="test-python-sdk-limited-key",
    bucket_access=client.object_storage.bucket_access(
        cluster_or_region=TEST_CLUSTER,
        bucket_name=bucket2.label,
        permissions=ObjectStorageKeyPermission.READ_ONLY,
        use_region=False,
    ),
)

print("Created with a cluster:")
print(bucket2._raw_json)
print(key2._raw_json)

key2.delete()
bucket2.delete()

@zliang-akamai zliang-akamai added the breaking-change for breaking changes in the changelog. label Jun 20, 2024
@zliang-akamai zliang-akamai changed the title Zhiwei/bucket key update Update OBJ Group and Objects for MultiCluster Object Storage API Changes Jun 20, 2024
@zliang-akamai zliang-akamai marked this pull request as ready for review June 21, 2024 06:20
@zliang-akamai zliang-akamai requested a review from a team as a code owner June 21, 2024 06:20
@zliang-akamai zliang-akamai requested review from lgarber-akamai and yec-akamai and removed request for a team June 21, 2024 06:20
Copy link
Contributor

@lgarber-akamai lgarber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing on my end and I haven't run into any more issues when testing against this from Ansible. Excellent work!

Copy link
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works locally, nice work!

id_attribute = "label"

properties = {
"cluster": Property(identifier=True),
"region": Property(identifier=True),
"cluster": Property(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a deprecated note to the cluster property as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the head up! I think there isn't a clear way to mark it as deprecated in Python since the property is in a dict... Let me think about it maybe we can modify Property class to accept a deprecation flag. I can do that in a future PR, I think.

@zliang-akamai zliang-akamai merged commit 8150255 into linode:proj/multicluster-obj Jul 2, 2024
7 checks passed
@zliang-akamai zliang-akamai deleted the zhiwei/bucket-key-update branch July 2, 2024 07:50
zliang-akamai added a commit that referenced this pull request Jul 5, 2024
* Add warnings to deprecated OBJ API usage (#410)

* add deprecated

* add dependency

* fix deprecated

* Update OBJ Group and Objects for MultiCluster Object Storage API Changes (#426)

---------

Co-authored-by: Ye Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change for breaking changes in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants