MCPcopy
hub / github.com/elastic/go-elasticsearch / Do

Method Do

esapi/api.xpack.ilm.put_lifecycle.go:74–190  ·  view source on GitHub ↗

Do executes the request and returns response or error.

(providedCtx context.Context, transport Transport)

Source from the content-addressed store, hash-verified

72
73// Do executes the request and returns response or error.
74func (r ILMPutLifecycleRequest) Do(providedCtx context.Context, transport Transport) (*Response, error) {
75 var (
76 method string
77 path strings.Builder
78 params map[string]string
79 ctx context.Context
80 )
81
82 if instrument, ok := r.Instrument.(Instrumentation); ok {
83 ctx = instrument.Start(providedCtx, "ilm.put_lifecycle")
84 defer instrument.Close(ctx)
85 }
86 if ctx == nil {
87 ctx = providedCtx
88 }
89
90 method = "PUT"
91
92 path.Grow(7 + 1 + len("_ilm") + 1 + len("policy") + 1 + len(r.Policy))
93 path.WriteString("http://")
94 path.WriteString("/")
95 path.WriteString("_ilm")
96 path.WriteString("/")
97 path.WriteString("policy")
98 path.WriteString("/")
99 path.WriteString(r.Policy)
100 if instrument, ok := r.Instrument.(Instrumentation); ok {
101 instrument.RecordPathPart(ctx, "policy", r.Policy)
102 }
103
104 params = make(map[string]string)
105
106 if r.MasterTimeout != 0 {
107 params["master_timeout"] = formatDuration(r.MasterTimeout)
108 }
109
110 if r.Timeout != 0 {
111 params["timeout"] = formatDuration(r.Timeout)
112 }
113
114 if r.Pretty {
115 params["pretty"] = "true"
116 }
117
118 if r.Human {
119 params["human"] = "true"
120 }
121
122 if r.ErrorTrace {
123 params["error_trace"] = "true"
124 }
125
126 if len(r.FilterPath) > 0 {
127 params["filter_path"] = strings.Join(r.FilterPath, ",")
128 }
129
130 req, err := newRequest(method, path.String(), r.Body)
131 if err != nil {

Callers

nothing calls this directly

Calls 15

formatDurationFunction · 0.85
newRequestFunction · 0.85
JoinMethod · 0.80
CloseMethod · 0.65
AddMethod · 0.65
PerformMethod · 0.65
StartMethod · 0.45
RecordPathPartMethod · 0.45
StringMethod · 0.45
RecordErrorMethod · 0.45
QueryMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected