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

Add delete_protected for mapped collections #920

Merged
merged 2 commits into from
Dec 12, 2023

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Dec 11, 2023

This is a new field in the MappedCollectionDocument definition.

As a bit of new testing art to try to validate the change, the unit
tests for the GCS helpers now include some signature-inspection tests

  • a test for optional bool settings. These are rather simplistic
    tests which might not offer a ton of value, but they're also very
    quick to execute.

📚 Documentation preview 📚: https://globus-sdk-python--920.org.readthedocs.build/en/920/

This is a new field in the MappedCollectionDocument definition.

As a bit of new testing art to try to validate the change, the unit
tests for the GCS helpers now include some signature-inspection tests
+ a test for optional bool settings. These are rather simplistic
tests which might not offer a ton of value, but they're also very
quick to execute.
@sirosen
Copy link
Member Author

sirosen commented Dec 12, 2023

I realized this morning that I omitted something important here, which is that delete_protected implies that the document type/version is collection#1.8.0. I'll make the requisite update and test it against a GCS I have running.

Fix the omission from DATATYPE_VERSION_IMPLICATIONS and add tests.
@sirosen
Copy link
Member Author

sirosen commented Dec 12, 2023

I've confirmed the fix. Example script included here.

example script setting `delete_protected=False`
import globus_sdk

CLIENT_ID = "61338d24-54d5-408f-a10d-66c06b59f6d2"
GCS_ID = "2111dd01-19b8-4720-963c-e72904b05645"
COLLECTION_ID = "6f4eab2f-5e4a-4280-aa54-30bdca0dbf07"
mc_scope = globus_sdk.GCSClient.get_gcs_endpoint_scopes(GCS_ID).manage_collections

client = globus_sdk.NativeAppAuthClient(CLIENT_ID)
client.oauth2_start_flow(
    requested_scopes=[globus_sdk.TransferClient.scopes.all, mc_scope],
    prefill_named_grant="spam",
)

authorize_url = client.oauth2_get_authorize_url()
print(f"Please go to this URL and login: {authorize_url}")

auth_code = input("Please enter the code you get after login here: ").strip()
token_response = client.oauth2_exchange_code_for_tokens(auth_code)

transfer_tokens = token_response.by_resource_server[
    globus_sdk.TransferClient.resource_server
]
gcs_tokens = token_response.by_resource_server[GCS_ID]

transfer_client = globus_sdk.TransferClient(
    authorizer=globus_sdk.AccessTokenAuthorizer(transfer_tokens["access_token"])
)

gcs_address = transfer_client.get_endpoint(GCS_ID)["gcs_manager_url"]

gcs_client = globus_sdk.GCSClient(
    f"{gcs_address}/api",
    authorizer=globus_sdk.AccessTokenAuthorizer(gcs_tokens["access_token"]),
)
collection_update_doc = globus_sdk.MappedCollectionDocument(delete_protected=False)
print(gcs_client.update_collection(COLLECTION_ID, collection_update_doc))

@sirosen sirosen merged commit 3bc55d7 into globus:main Dec 12, 2023
16 checks passed
@sirosen sirosen mentioned this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants