GetAPIKeys fetches the list of API keys. API returns {"api-keys": [...]}.
()
| 237 | // GetAPIKeys fetches the list of API keys. |
| 238 | // API returns {"api-keys": [...]}. |
| 239 | func (c *Client) GetAPIKeys() ([]string, error) { |
| 240 | wrapper, err := c.getJSON("/v0/management/api-keys") |
| 241 | if err != nil { |
| 242 | return nil, err |
| 243 | } |
| 244 | arr, ok := wrapper["api-keys"] |
| 245 | if !ok { |
| 246 | return nil, nil |
| 247 | } |
| 248 | raw, err := json.Marshal(arr) |
| 249 | if err != nil { |
| 250 | return nil, err |
| 251 | } |
| 252 | var result []string |
| 253 | if err := json.Unmarshal(raw, &result); err != nil { |
| 254 | return nil, err |
| 255 | } |
| 256 | return result, nil |
| 257 | } |
| 258 | |
| 259 | // AddAPIKey adds a new API key by sending old=nil, new=key which appends. |
| 260 | func (c *Client) AddAPIKey(key string) error { |