[go: nahoru, domu]

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

storage: Bucket lock lockRetentionPolicy does not return Bucket Attrs (FR: Storage V2) #1159

Open
frankyn opened this issue Sep 24, 2018 · 7 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@frankyn
Copy link
Member
frankyn commented Sep 24, 2018

Hi @jadekler,

At the moment I'm unable to get the Bucket Attrs returns after locking a retention policy and have to perform a subsequent bucket.Attrs() request after locking a retention policy. This will help reduce the number of requests made to one instead of two.

Existing Behavior:

        bucket := c.Bucket(bucketName)
	attrs, err := c.Bucket(bucketName).Attrs(ctx)
	if err != nil {
		return err
	}

	conditions := storage.BucketConditions{
		MetagenerationMatch: attrs.MetaGeneration,
	}
	if err := bucket.If(conditions).LockRetentionPolicy(ctx); err != nil {
		return err
	}

	lockedAttrs, lockedErr := c.Bucket(bucketName).Attrs(ctx)
	if lockedErr != nil {
		return err
	}
	fmt.Printf("Retention policy for %v is now locked\n", bucketName)
	fmt.Printf("Retention policy effective as of %v\n",
		lockedAttrs.RetentionPolicy.EffectiveTime)

Expected behavior:

        bucket := c.Bucket(bucketName)
	attrs, err := c.Bucket(bucketName).Attrs(ctx)
	if err != nil {
		return err
	}

	conditions := storage.BucketConditions{
		MetagenerationMatch: attrs.MetaGeneration,
	}
	lockedAttrs, err := bucket.If(conditions).LockRetentionPolicy(ctx)
         if err != nil {
		return err
	}
	fmt.Printf("Retention policy for %v is now locked\n", bucketName)
	fmt.Printf("Retention policy effective as of %v\n",
		lockedAttrs.RetentionPolicy.EffectiveTime)
@jeanbza
Copy link
Member
jeanbza commented Sep 24, 2018

Two questions:

  • What are the advantages? Just reducing the number of calls from 2 to 1?
  • Does the Lock RPC give us these attributes (in json form)?

@frankyn
Copy link
Member Author
frankyn commented Sep 24, 2018

What are the advantages? Just reducing the number of calls from 2 to 1?

Yes, it also surfaces the available response from this RPC.

Does the Lock RPC give us these attributes (in json form)?

Yes, per the Discovery Doc it returns a Bucket JSON resource in the response.

"lockRetentionPolicy": {
     "id": "storage.buckets.lockRetentionPolicy",
     "path": "b/{bucket}/lockRetentionPolicy",
     "httpMethod": "POST",
     "description": "Locks retention policy on a bucket.",
     "parameters": {
      "bucket": {
       "type": "string",
       "description": "Name of a bucket.",
       "required": true,
       "location": "path"
      },
      "ifMetagenerationMatch": {
       "type": "string",
       "description": "Makes the operation conditional on whether bucket's current metageneration matches the given value.",
       "required": true,
       "format": "int64",
       "location": "query"
      },
      "userProject": {
       "type": "string",
       "description": "The project to be billed for this request. Required for Requester Pays buckets.",
       "location": "query"
      }
     },
     "parameterOrder": [
      "bucket",
      "ifMetagenerationMatch"
     ],
     "response": {
      "$ref": "Bucket"
     },
     "scopes": [
      "https://www.googleapis.com/auth/cloud-platform",
      "https://www.googleapis.com/auth/devstorage.full_control",
      "https://www.googleapis.com/auth/devstorage.read_write"
     ]
    },

@jba
Copy link
Contributor
jba commented Sep 24, 2018

We can't make breaking changes to a stable package.

We could either (1) write a new function, if you think it's worth it, or (2) make this an FR for v2 of the storage client.

@frankyn
Copy link
Member Author
frankyn commented Sep 24, 2018

Thanks both, let's mark it as FR for v2. Current implementation doesn't block developers.

@frankyn frankyn added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: storage Issues related to the Cloud Storage API. labels Sep 24, 2018
@frankyn frankyn changed the title Storage: Bucket lock lockRetentionPolicy does not return Bucket Attrs Storage: Bucket lock lockRetentionPolicy does not return Bucket Attrs (FR: Storage V2) Sep 24, 2018
@odeke-em odeke-em changed the title Storage: Bucket lock lockRetentionPolicy does not return Bucket Attrs (FR: Storage V2) storage: Bucket lock lockRetentionPolicy does not return Bucket Attrs (FR: Storage V2) Jul 14, 2019
@jeanbza jeanbza removed their assignment Jul 15, 2019
@odeke-em
Copy link
Contributor

Hello @frankyn, I see this is marked as feature request for the v2 version of the storage client. Unless am mistaken but we aren't going to be working on that anytime soon, can this issue then be closed or perhaps documented elsewhere as a feature request or do we keep it open for the v2 wishlist, whenever v2 is worked on?

@frankyn
Copy link
Member Author
frankyn commented Aug 15, 2019

We may want to fix it if that's the case. I haven't heard any plans about v2 either. Is it a real thing?

@jeanbza
Copy link
Member
jeanbza commented Aug 15, 2019

No, but we have several bugs of this ilk where we talk about things we'd like if we were to start going down a v2 road.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants