Andy Gross  committed 4f3f9a7

update @docs in jiak_resource with documentation on bucket-schema PUT requests

  • Participants
  • Parent commits af6394a
  • Branches default

Comments (0)

Files changed (1)

File src/jiak_resource.erl

 %%            a new, server-generated key.  Response will be empty (unless
 %%            returnbody=true is specified in the query parameters) with
 %%            the Location header set to the new object's URI.
+%%</dd><dt> PUT /JiakBase/Bucket
+%%</dt><dd>   Create or update the schema for a bucket.  The request body 
+%%            must be a JSON object of the form:
+%%            {"schema":{
+%%                      "allowed_fields":["FieldName1","FieldName2",...],
+%%                      "required_fields":["FieldName1",...],
+%%                      "write_mask":["FieldName1",...],
+%%                      "read_mask":["FieldName1",...]
+%%                     }
+%%            }
 %%          {[http_method()], webmachine:wrq(), context()}
 %% @type http_method() = 'HEAD'|'GET'|'POST'|'PUT'|'DELETE'
 %% @doc Determine the list of HTTP methods that can be used on this
-%%      resource.  Should be HEAD/GET/POST for buckets and
+%%      resource.  Should be HEAD/GET/POST/PUT for buckets and
 %%      HEAD/GET/POST/PUT/DELETE for objects.
 %%      Exception: HEAD/GET is returned for an "unknown" bucket.
 allowed_methods(RD, Ctx0=#ctx{module=Mod}) ->
 %%          bucket component of the URI
 %%        - the "key" field of the object does not match the
 %%          key component of the URI
+%%        - when PUTing to a bucket schema, the schema is not of the
+%%          form described above. 
 malformed_request(ReqData, Context=#ctx{key=schema}) ->
     case decode_object(wrq:req_body(ReqData)) of
         {ok, _SchemaObj={struct, SchemaPL0}} ->
 %% @doc For an object GET/PUT/POST or a bucket POST, check to see
 %%      whether the write request violates the write mask of the
 %%      bucket.  For a bucket GET, check to see whether the keys of
-%%      the bucket are listable.
+%%      the bucket are listable.  PUT requests to bucket schemas are
+%%      always accepted.
 forbidden(ReqData, Context=#ctx{key=schema}) ->
     %% PUTs to container are for setting schemas and therefore always
     %% allowed