def insert_magic_bucket(base_url): if len(testbench_utils.all_buckets()) == 0: bucket_name = os.environ.get( "GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME", "test-bucket" ) bucket = gcs_bucket.GcsBucket(base_url, bucket_name) testbench_utils.insert_bucket(bucket_name, bucket)
def buckets_list(): """Implement the 'Buckets: list' API: return the Buckets in a project.""" base_url = flask.url_for('gcs_index', _external=True) project = flask.request.args.get('project') if project is None or project.endswith('-'): raise error_response.ErrorResponse( 'Invalid or missing project id in `Buckets: list`') insert_magic_bucket(base_url) result = {'next_page_token': '', 'items': []} for name, b in testbench_utils.all_buckets(): result['items'].append(b.metadata) return testbench_utils.filtered_response(flask.request, result)
def insert_magic_bucket(base_url): if len(testbench_utils.all_buckets()) == 0: bucket_name = os.environ.get('BUCKET_NAME', 'test-bucket') bucket = gcs_bucket.GcsBucket(base_url, bucket_name) # Enable versioning in the Bucket, the integration tests expect this to # be the case, this brings the metageneration number to 2. bucket.update_from_metadata({'versioning': {'enabled': True}}) # Perform trivial updates that bring the metageneration to 4, the value # expected by the integration tests. bucket.update_from_metadata({}) bucket.update_from_metadata({}) testbench_utils.insert_bucket(bucket_name, bucket)
def buckets_list(): """Implement the 'Buckets: list' API: return the Buckets in a project.""" base_url = flask.url_for("gcs_index", _external=True) project = flask.request.args.get("project") if project is None or project.endswith("-"): raise error_response.ErrorResponse( "Invalid or missing project id in `Buckets: list`") insert_magic_bucket(base_url) result = {"next_page_token": "", "items": []} for name, b in testbench_utils.all_buckets(): result["items"].append(b.metadata) return testbench_utils.filtered_response(flask.request, result)
def insert_magic_bucket(base_url): if len(testbench_utils.all_buckets()) == 0: bucket_name = os.environ.get( "GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME", "test-bucket") bucket = gcs_bucket.GcsBucket(base_url, bucket_name) # Enable versioning in the Bucket, the integration tests expect this to # be the case, this brings the metageneration number to 2. bucket.update_from_metadata({"versioning": {"enabled": True}}) # Perform trivial updates that bring the metageneration to 4, the value # expected by the integration tests. bucket.update_from_metadata({}) bucket.update_from_metadata({}) testbench_utils.insert_bucket(bucket_name, bucket)