> +   @Named("b2_create_bucket")
> +   @POST
> +   @Path("/b2api/v1/b2_create_bucket")
> +   @MapBinder(BindToJsonPayload.class)
> +   @PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   Bucket createBucket(@PayloadParam("bucketName") String bucketName, 
> @PayloadParam("bucketType") BucketType bucketType);
> +
> +   @Named("b2_delete_bucket")
> +   @POST
> +   @Path("/b2api/v1/b2_delete_bucket")
> +   @MapBinder(BindToJsonPayload.class)
> +   @PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)

Yes, it does not return a 404, but it actually throws a 
ResourceNotFoundException when the referenced bucket is not found (which in 
practice, for jclouds is just the same as if it had returned a 404).

What I mean, is that a common practice in jclouds is to avoid failing on delete 
operations if the resource to be deleted does not exist. [The S3 
API](https://github.com/jclouds/jclouds/blob/master/apis/s3/src/main/java/org/jclouds/s3/S3Client.java#L207)
 and many others behave this way, and I think it would be good to follow that 
pattern here too.

If you annotate this method with `@Fallback(NullOnNotFoundOr404.class)`, then 
the method will not fail and just return `null` when the resource to be deleted 
does not exist, just like most of the other jclouds APIs. The fallback will not 
only take place if the response is a 404, [but also if the call generated a 
ResoueceNotFoundException](https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/Fallbacks.java#L138-L140).
 Don't be "distracted" by the "Or404" in the fallback name; it checks for 
exceptions too, and your error handler already takes care of properly setting 
it when appropriate, so APIs can use this kind of callbacks.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/270/files/8bb355e1b286b2bbf77fd8d3cb75cd2d1aa6bc69#r64715048

Reply via email to