コード例 #1
0
ファイル: buckets.py プロジェクト: ZettaAI/cloud-bot-workers
def create(ctx, *args, **kwargs):
    admin_check(ctx.obj["user_id"])
    bucket = Bucket(ctx.obj["client"], name=ctx.obj["name"])
    bucket.location = kwargs["location"].upper()
    bucket.storage_class = kwargs["class"].upper()
    bucket.create()
    return f"Bucket `{bucket.name}` created."
コード例 #2
0
def storage(request):
    # create a random test bucket name
    bucket_name = "test_bucket_" + get_random_string(6, string.ascii_lowercase)

    storage = DjangoGCloudStorage(
        project=request.config.getoption("--gcs-project-name"),
        bucket=bucket_name,
        credentials_file_path=request.config.getoption(
            "--gcs-credentials-file"))

    # Make sure the bucket exists
    bucket = Bucket(storage.client, bucket_name)
    bucket.create(location=request.config.getoption("--gcs-bucket-location"))

    yield storage

    storage.bucket.delete_blobs(storage.bucket.list_blobs())

    storage.bucket.delete(force=True)
コード例 #3
0
def storage(request):
    # create a random test bucket name
    bucket_name = "test_bucket_" + get_random_string(6, string.ascii_lowercase)

    storage = DjangoGCloudStorage(
        project=request.config.getoption("--gcs-project-name"),
        bucket=bucket_name,
        credentials_file_path=request.config.getoption("--gcs-credentials-file")
    )

    # Make sure the bucket exists
    bucket = Bucket(storage.client, bucket_name)
    bucket.location = request.config.getoption("--gcs-bucket-location")
    bucket.create()

    yield storage

    storage.bucket.delete_blobs(storage.bucket.list_blobs())

    storage.bucket.delete(force=True)
コード例 #4
0
ファイル: gs_client.py プロジェクト: wilmeragsgh/spotty
    def create_bucket(self, bucket_name: str, region: str) -> Bucket:
        bucket = Bucket(self._client, name=bucket_name)
        bucket.create(location=region)

        return bucket