36
36
// CreateContainer creates a container with the given name.
37
37
func (c *Client) CreateContainer(containerName string, acl ACL) error {
38
// [sodre]: Due to a possible bug in ceph-radosgw, we need to split the
39
// creation of the bucket and the changing its ACL.
40
requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted, http.StatusCreated}}
41
err := c.client.SendRequest(client.PUT, "object-store", containerName, &requestData)
43
err = maybeNotFound(err, "failed to create container: %s", containerName)
38
46
// Normally accessing a container or objects within requires a token
39
47
// for the tenant. Setting an ACL using the X-Container-Read header
40
48
// can be used to allow unauthenticated HTTP access.
41
49
headers := make(http.Header)
42
50
headers.Add("X-Container-Read", string(acl))
43
requestData := goosehttp.RequestData{ReqHeaders: headers, ExpectedStatus: []int{http.StatusAccepted, http.StatusCreated}}
44
err := c.client.SendRequest(client.PUT, "object-store", containerName, &requestData)
51
requestData = goosehttp.RequestData{ReqHeaders: headers,
52
ExpectedStatus: []int{http.StatusAccepted, http.StatusNoContent}}
53
err = c.client.SendRequest(client.POST, "object-store", containerName, &requestData)
46
err = maybeNotFound(err, "failed to create container: %s", containerName)
55
err = maybeNotFound(err, "failed to update container read acl: %s", containerName)
134
143
params.Add("prefix", prefix)
135
144
params.Add("delimiter", delim)
136
145
params.Add("marker", marker)
146
params.Add("format", "json")
138
148
params.Add("limit", fmt.Sprintf("%d", limit))