MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / FetchPricingBatch

Method FetchPricingBatch

internal/api/client.go:167–189  ·  view source on GitHub ↗
(requests BatchPricingRequest)

Source from the content-addressed store, hash-verified

165}
166
167func (c *Client) FetchPricingBatch(requests BatchPricingRequest) (*BatchPricingApiResponse, error) {
168 endpoint := APIBaseURL + "/pricing/batch"
169 status, respBytes, err := c.post(endpoint, requests, true)
170 if err != nil {
171 return nil, fmt.Errorf("failed to connect to batch pricing API: %w", err)
172 }
173 if status == http.StatusNotFound {
174 return nil, nil
175 }
176 if status >= 300 {
177 return nil, fmt.Errorf("batch pricing request failed (%d): %s", status, string(respBytes))
178 }
179
180 var result BatchPricingApiResponse
181 if err := json.Unmarshal(respBytes, &result); err != nil {
182 preview := string(respBytes)
183 if len(preview) > 500 {
184 preview = preview[:500]
185 }
186 return nil, fmt.Errorf("failed to parse batch pricing response: %w (first 500 chars: %s)", err, preview)
187 }
188 return &result, nil
189}
190
191// DownloadMetadataGz downloads /pricing/metadata and saves as metadata.json.gz.
192func (c *Client) DownloadMetadataGz() error {

Callers

nothing calls this directly

Calls 1

postMethod · 0.95

Tested by

no test coverage detected