DownloadMetadataGz downloads /pricing/metadata and saves as metadata.json.gz.
()
| 190 | |
| 191 | // DownloadMetadataGz downloads /pricing/metadata and saves as metadata.json.gz. |
| 192 | func (c *Client) DownloadMetadataGz() error { |
| 193 | status, data, err := c.get(APIBaseURL+"/pricing/metadata", true) |
| 194 | if err != nil { |
| 195 | return fmt.Errorf("failed to download metadata: %w", err) |
| 196 | } |
| 197 | if status >= 300 { |
| 198 | return fmt.Errorf("failed to download metadata (%d): %s", status, string(data)) |
| 199 | } |
| 200 | |
| 201 | p, err := config.MetadataGzPath() |
| 202 | if err != nil { |
| 203 | return err |
| 204 | } |
| 205 | return os.WriteFile(p, data, 0o644) |
| 206 | } |
| 207 | |
| 208 | // LoadMetadataFromFile reads and decompresses ~/.cloudcent/metadata.json.gz. |
| 209 | func LoadMetadataFromFile() (*MetadataResponse, error) { |