MCPcopy
hub / github.com/cloudfoundry/cli / createUpdateOrDeleteResource

Method createUpdateOrDeleteResource

cf/net/gateway.go:168–195  ·  view source on GitHub ↗
(verb, endpoint, apiURL string, body io.ReadSeeker, sync bool, optionalResource ...interface{})

Source from the content-addressed store, hash-verified

166}
167
168func (gateway Gateway) createUpdateOrDeleteResource(verb, endpoint, apiURL string, body io.ReadSeeker, sync bool, optionalResource ...interface{}) error {
169 var resource interface{}
170 if len(optionalResource) > 0 {
171 resource = optionalResource[0]
172 }
173
174 request, err := gateway.NewRequest(verb, endpoint+apiURL, gateway.config.AccessToken(), body)
175 if err != nil {
176 return err
177 }
178
179 if resource == nil {
180 _, err = gateway.PerformRequest(request)
181 return err
182 }
183
184 if gateway.PollingEnabled && !sync {
185 _, err = gateway.PerformPollingRequestForJSONResponse(endpoint, request, resource, gateway.AsyncTimeout())
186 return err
187 }
188
189 _, err = gateway.PerformRequestForJSONResponse(request, resource)
190 if err != nil {
191 return err
192 }
193
194 return nil
195}
196
197func (gateway Gateway) newRequest(request *http.Request, accessToken string, body io.ReadSeeker) *Request {
198 if accessToken != "" {

Callers 5

CreateResourceMethod · 0.95
UpdateResourceMethod · 0.95
UpdateResourceSyncMethod · 0.95
DeleteResourceMethod · 0.95

Calls 6

NewRequestMethod · 0.95
PerformRequestMethod · 0.95
AsyncTimeoutMethod · 0.95
AccessTokenMethod · 0.65

Tested by

no test coverage detected