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

Additional bucket response attributes #1258

Merged
merged 3 commits into from
Jul 30, 2023
Merged

Additional bucket response attributes #1258

merged 3 commits into from
Jul 30, 2023

Conversation

manuteleco
Copy link
Contributor

Include additional attributes in Bucket responses, so that fake-gcs-server can be used with certain client libraries that rely on those attributes being there (like googleCloudStorageR).

With these changes we include three additional attributes: timeCreated (was already present when using the Memory backend), updated and storageClass.

So we go from:

curl -s 'http://localhost:8080/storage/v1/b/?project=my-dummy-project-id' | jq
{
  "kind": "storage#buckets",
  "items": [
    {
      "kind": "storage#bucket",
      "id": "my-bucket",
      "name": "my-bucket",
      "versioning": {},
      "location": "US-CENTRAL1"
    }
  ]
}

to:

curl -s 'http://localhost:8080/storage/v1/b/?project=my-dummy-project-id' | jq
{
  "kind": "storage#buckets",
  "items": [
    {
      "kind": "storage#bucket",
      "id": "my-bucket",
      "name": "my-bucket",
      "versioning": {},
      "timeCreated": "2023-07-22T09:01:26.287332+02:00",
      "updated": "2023-07-22T09:01:26.287332+02:00",
      "location": "US-CENTRAL1",
      "storageClass": "STANDARD"
    }
  ]
}

Copy link
Owner

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

Can you add some tests?

This was already supported in the Memory backend.

As bucket creation time we use the creation time attribute of the
filesystem directory node backing it.
Some client libraries, like [googleCloudStorageR][1], expect the
`updated` attribute of the [Bucket][2] object to be returned.

Its value isn't hugely important, so we just use the same value as for
`timeCreated`, also considering that update timestamps are not being
tracked yet.

[1]: https://cran.r-project.org/web/packages/googleCloudStorageR
[2]: https://cloud.google.com/storage/docs/json_api/v1/buckets
Some client libraries, like [googleCloudStorageR][1], expect the
`storageClass` attribute of the [Bucket][2] object to be returned.

Its value isn't hugely important, so we just use "STANDARD".

[1]: https://cran.r-project.org/web/packages/googleCloudStorageR
[2]: https://cloud.google.com/storage/docs/json_api/v1/buckets
Copy link
Owner

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@fsouza fsouza merged commit e1e8229 into fsouza:main Jul 30, 2023
@manuteleco manuteleco deleted the additional_bucket_response_attributes branch July 30, 2023 15:54
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