Given cos.SimpleKVs (map[string]string) keys and values, sets object's custom properties. By default, adds new or updates existing custom keys. Use `setNewCustomMDFlag` to _replace_ all existing keys with the specified (new) ones. See also: HeadObject() and apc.HdrObjCustomMD
(baseParams BaseParams, bck cmn.Bck, object string, custom cos.SimpleKVs, setNew bool)
| 198 | // Use `setNewCustomMDFlag` to _replace_ all existing keys with the specified (new) ones. |
| 199 | // See also: HeadObject() and apc.HdrObjCustomMD |
| 200 | func SetObjectCustomProps(baseParams BaseParams, bck cmn.Bck, object string, custom cos.SimpleKVs, setNew bool) error { |
| 201 | var ( |
| 202 | actMsg = apc.ActionMsg{Value: custom} |
| 203 | q url.Values |
| 204 | ) |
| 205 | if setNew { |
| 206 | q = make(url.Values, 4) |
| 207 | q = bck.AddToQuery(q) |
| 208 | q.Set(apc.QparamNewCustom, "true") |
| 209 | } else { |
| 210 | q = bck.AddToQuery(q) |
| 211 | } |
| 212 | baseParams.Method = http.MethodPatch |
| 213 | reqParams := AllocRp() |
| 214 | { |
| 215 | reqParams.BaseParams = baseParams |
| 216 | reqParams.Path = apc.URLPathObjects.Join(bck.Name, object) |
| 217 | reqParams.Body = cos.MustMarshal(actMsg) |
| 218 | reqParams.Header = http.Header{cos.HdrContentType: []string{cos.ContentJSON}} |
| 219 | reqParams.Query = q |
| 220 | } |
| 221 | err := reqParams.DoHTTPRequest() |
| 222 | FreeRp(reqParams) |
| 223 | return err |
| 224 | } |
| 225 | |
| 226 | // DeleteObject deletes an object specified by bucket/object. |
| 227 | func DeleteObject(baseParams BaseParams, bck cmn.Bck, object string) error { |
no test coverage detected