@@ -28,6 +28,7 @@ import (
2828 "io"
2929 "io/ioutil"
3030 "net/http"
31+ "net/url"
3132 "os"
3233 "time"
3334)
@@ -40,21 +41,25 @@ type analyzeRequestBody struct {
4041// Example:
4142// {"customerId": "C10000", "accountId": "139710491120", "executionId": "ondemand-C10000-139710491120-2022-09-15_TV49"}
4243type analyzeResponseBody struct {
43- CustomerID string `json:"customerId"`
44- Account string `json:"accountId"`
44+ CustomerID string `json:"customerId"`
45+ Account string `json:"accountId"`
4546 ExecutionID string `json:"executionId"`
4647}
4748
4849func AnalyzeAccount (o io.Writer , cfg aws.Config , apiHost , customerID , account string ) error {
49- url := fmt .Sprintf ("https://%s/analysis/account" , apiHost )
50+ analysisUrl := & url.URL {
51+ Scheme : "https" ,
52+ Host : apiHost ,
53+ Path : fmt .Sprintf ("/customer/%s/account/%s/analysis" , customerID , account ),
54+ }
5055
5156 requestBody := analyzeRequestBody {
5257 CustomerID : customerID ,
5358 Account : account ,
5459 }
5560 requestBodyBytes , _ := json .Marshal (requestBody )
5661
57- request , err := http .NewRequest ("POST" , url , bytes .NewBuffer (requestBodyBytes ))
62+ request , err := http .NewRequest ("POST" , analysisUrl . String () , bytes .NewBuffer (requestBodyBytes ))
5863 if err != nil {
5964 fmt .Fprintf (os .Stderr , "Could not build API request: %s\n " , err )
6065 return err
@@ -90,7 +95,7 @@ func AnalyzeAccount(o io.Writer, cfg aws.Config, apiHost, customerID, account st
9095 account ,
9196 analyzeResponse .ExecutionID )
9297 } else {
93- fmt .Fprintf (os .Stderr ,"Analyze API Response Status: %s\n " , response .Status )
98+ fmt .Fprintf (os .Stderr , "Analyze API Response Status: %s\n " , response .Status )
9499 fmt .Fprintf (os .Stderr , "Could not start analysis for %s account %s. API Response: %s\n " ,
95100 customerID ,
96101 account ,
@@ -138,7 +143,7 @@ func createPayloadHash(req *http.Request) (string, error) {
138143 if err != nil {
139144 return "" , err
140145 }
141-
146+
142147 b := sha256 .Sum256 (buf .Bytes ())
143148 return hex .EncodeToString (b [:]), nil
144149}
0 commit comments