()
| 263 | } |
| 264 | |
| 265 | func (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 | |
| 289 | func (gohanClientCLI *GohanClientCLI) getSchemaByID(id string) (*schema.Schema, error) { |
| 290 | for _, s := range gohanClientCLI.schemas { |
no test coverage detected