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

feat: View and create Storage methods using SDK #206

Conversation

AvanishCodes
Copy link
Collaborator

@AvanishCodes AvanishCodes commented Dec 13, 2024

Test Script

Please change the UPPERCASE Variable values before running

import uuid
import redbrick
from redbrick.types.storage_method import (
    InputAltaDBStorageMethodDetails,
    InputAWSS3StorageMethodDetails,
    InputAzureBlobStorageMethodDetails,
    InputGCSStorageMethodDetails,
)


KEY = ""
ORG_ID = ""
RBAI_URL = ""


# Flow 709 testing
ALTADB_API_KEY = ""
ALTADB_SECRET = ""
ALTADB_URL = ""

org = redbrick.get_org(ORG_ID, KEY, RBAI_URL)

client = org.context.client
print(client)

storage_name = f"test_storage-{uuid.uuid4()}"
print(storage_name)
org.context.storage_method.create_storage_method(
    org_id=ORG_ID,
    name=storage_name,
    provider=redbrick.StorageProvider.ALTA_DB,
    details=InputAltaDBStorageMethodDetails(
        access=ALTADB_API_KEY,
        secret=ALTADB_SECRET,
        host=ALTADB_URL,
    ),
)
print("AltaDB: SUCCESS")
storage_name = f"test_storage-{uuid.uuid4()}"
org.context.storage_method.create_storage_method(
    org_id=ORG_ID,
    name=storage_name,
    provider=redbrick.StorageProvider.AWS_S3,
    details=InputAWSS3StorageMethodDetails(
        access="AKIAIOSFODNN7EXAMPLE",
        secret="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
        bucket="examplebucket",
        region="us-west-2",
    ),
)
print("AWS S3: SUCCESS")
storage_name = f"test_storage-{uuid.uuid4()}"
org.context.storage_method.create_storage_method(
    org_id=ORG_ID,
    name=storage_name,
    provider=redbrick.StorageProvider.AZURE_BLOB,
    details=InputAzureBlobStorageMethodDetails(
        connectionString="DefaultEndpointsProtocol=https;AccountName=example;AccountKey=example",
    ),
)
storage_name = f"test_storage-{uuid.uuid4()}"
org.context.storage_method.create_storage_method(
    org_id=ORG_ID,
    name=storage_name,
    provider=redbrick.StorageProvider.AZURE_BLOB,
    details=InputAzureBlobStorageMethodDetails(
        sasUrl="https://example.blob.core.windows.net/?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-07-10T05:40:34Z&st=2020-07-09T21:40:34Z&spr=https&sig=example",
    ),
)
print("Azure Blob: SUCCESS")
storage_name = f"test_storage-{uuid.uuid4()}"
org.context.storage_method.create_storage_method(
    org_id=ORG_ID,
    name=storage_name,
    provider=redbrick.StorageProvider.GCS,
    details=InputGCSStorageMethodDetails(
        bucket="example",
        serviceAccount='{"project_id": "example", "private_key": "example"}',
    ),
)
print("GCS: SUCCESS")

storage_methods = org.context.storage_method.get_storage_methods(org_id=ORG_ID)
assert storage_methods
assert any(storage_name in storage_method["name"] for storage_method in storage_methods)

@AvanishCodes AvanishCodes self-assigned this Dec 13, 2024
@AvanishCodes AvanishCodes marked this pull request as ready for review December 16, 2024 08:50
Copy link

codecov bot commented Dec 16, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@pritamrungta pritamrungta deleted the avanish/flow-709-create-a-new-storage-method-using-sdk branch December 16, 2024 12:05
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