Backblaze / b2-sdk-java

The official Java SDK for using Backblaze's B2 Storage APIs
Other
94 stars 25 forks source link

revision is not optional in B2UpdateBucketRequest #125

Open z0mb1ek opened 4 years ago

z0mb1ek commented 4 years ago

Hi. We need B2Bucket to construct B2UpdateBucketRequest, but in B2Bucket revision is not optional field @B2Json.required private final int revision;

certainmagic commented 4 years ago

Hi Dmitry --

Sorry for the delay in responding. I was backpacking last week.

I see that I have the following comment in B2UpdateBucketRequest.Builder:

// XXX: should i let people opt-out of using ifRevisionIs? let's see if anyone needs it!

Congrats on being the first person to ask about it. :)

Can you tell us more about your use case? What are you changing about a bucket that you don't already have a bucket object from the service to start from? Or is it just that you don't want ifRevisionIs to be set? Or...?

thanks, ab

z0mb1ek commented 4 years ago

Hi. I want programmaticaly change cors for example on bucket

certainmagic commented 4 years ago

The intention is that you fetch the current version of the bucket and use that as input to the request. It sounds like maybe you don't have the current version of the bucket to start with?

On Wed, Sep 9, 2020 at 3:01 PM Dmitry Fedorov notifications@github.com wrote:

Hi. I want programmaticaly change cors for example on bucket

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Backblaze/b2-sdk-java/issues/125#issuecomment-689620820, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHJFCX3LJVJZZZEAQOBE3LSE6KEDANCNFSM4QPP7MWQ .

z0mb1ek commented 4 years ago

Yes, i don't have version, I want just +1

certainmagic commented 4 years ago

So today your code calls new B2Bucket(....) from scratch and then passes that to B2UpdateBucketRequest.builder()?

On Wed, Sep 9, 2020 at 3:08 PM Dmitry Fedorov notifications@github.com wrote:

Yes, i don't have version, I want just +1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Backblaze/b2-sdk-java/issues/125#issuecomment-689625508, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHJFCSCOHNHUUTJ5GTU4EDSE6K7TANCNFSM4QPP7MWQ .

z0mb1ek commented 4 years ago

No, I have a created bucket. And than I want just update it

certainmagic commented 4 years ago

I'm still trying to understand the core of the issue you're having. Does either of these work for you?

Do you have a B2Bucket object for the previously created bucket, or just the accountId and bucketId? (The B2Bucket object in the SDK isn't currently intended to be created by SDK clients -- that's why there's no Builder class for it.)

thanks, ab

z0mb1ek commented 4 years ago

I have just the accountId and bucketId

certainmagic commented 4 years ago

As mentioned in the documentation, the ifRevisionIs parameter is used to detect conflicting updates to a bucket. It sounds like you don't care about that and that you want to make the change unconditionally.

I would propose adding this to B2UpdateBucketRequest.Builder:

private Builder(String accountId, String bucketId) { this. accountId = accountId; this.bucketId = bucketId; }

and adding this to B2UpdateBucketRequest:

public static Builder builder(String accountId, String bucketId) { return new Builder(accountId, bucketId); }

and updating the comment at the start of the Builder class.

And then you'll be able to create the request directly without specifying a version and without having to make a dummy bucket object.

How does that sound? Are you willing to make a PR?

thanks, ab

On Wed, Sep 9, 2020 at 3:44 PM Dmitry Fedorov notifications@github.com wrote:

I have just the accountId and bucketId

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Backblaze/b2-sdk-java/issues/125#issuecomment-689648059, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHJFCTC6J3T6BOZ4GRWTZ3SE6PHFANCNFSM4QPP7MWQ .