MCPcopy Index your code
hub / github.com/NVIDIA/aistore / SetObjectCustomProps

Function SetObjectCustomProps

api/object.go:200–224  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

198// Use `setNewCustomMDFlag` to _replace_ all existing keys with the specified (new) ones.
199// See also: HeadObject() and apc.HdrObjCustomMD
200func 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.
227func DeleteObject(baseParams BaseParams, bck cmn.Bck, object string) error {

Callers 1

setCustomPropsFunction · 0.92

Calls 7

MustMarshalFunction · 0.92
AllocRpFunction · 0.85
FreeRpFunction · 0.85
JoinMethod · 0.80
DoHTTPRequestMethod · 0.80
SetMethod · 0.65
AddToQueryMethod · 0.45

Tested by

no test coverage detected