MCPcopy Create free account
hub / github.com/cloudwan/gohan / getSchemas

Method getSchemas

cli/client/client.go:265–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

263}
264
265func (gohanClientCLI *GohanClientCLI) getSchemas() ([]*schema.Schema, error) {
266 jsonResponse := make(map[string]interface{})
267 url := fmt.Sprintf("%s%s", gohanClientCLI.opts.gohanEndpointURL, gohanClientCLI.opts.gohanSchemaURL)
268 gohanClientCLI.logRequest("GET", url, gohanClientCLI.provider.TokenID, nil)
269 _, err := gohanClientCLI.provider.Request(http.MethodGet, url, &gophercloud.RequestOpts{JSONResponse: &jsonResponse})
270 if err != nil {
271 return nil, err
272 }
273
274 if _, ok := jsonResponse["schemas"]; !ok {
275 return nil, fmt.Errorf("No 'schemas' key in response JSON")
276 }
277
278 result := []*schema.Schema{}
279 for _, rawSchema := range jsonResponse["schemas"].([]interface{}) {
280 schema, err := schema.NewSchemaFromObj(rawSchema)
281 if err != nil {
282 return nil, fmt.Errorf("Could not parse schemas: %v", err)
283 }
284 result = append(result, schema)
285 }
286 return result, nil
287}
288
289func (gohanClientCLI *GohanClientCLI) getSchemaByID(id string) (*schema.Schema, error) {
290 for _, s := range gohanClientCLI.schemas {

Callers 4

getCachedSchemasMethod · 0.95
outputSubCommandsMethod · 0.95
NewGohanClientCLIFunction · 0.95
client_test.goFile · 0.80

Calls 3

logRequestMethod · 0.95
RequestMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected