@@ -39,6 +39,20 @@ type ArcInstance struct {
3939 SubscriptionID string `json:"subscription_id"`
4040}
4141
42+ type arcInstanceDetails struct {
43+ NodeCount int64 `json:"node_count"`
44+ Description string `json:"description"`
45+ SubscriptionID string `json:"subscription_id"`
46+ SubscriptionCanceled bool `json:"subscription_canceled"`
47+ Trial bool `json:"trial"`
48+ TrialValidity int64 `json:"trial_validity"`
49+ ArcID string `json:"arc_id"`
50+ CreatedAt int64 `json:"created_at"`
51+ Tier string `json:"tier"`
52+ TierValidity int64 `json:"tier_validity"`
53+ Metadata map [string ]interface {} `json:"metadata"`
54+ }
55+
4256const (
4357 envEsURL = "ES_CLUSTER_URL"
4458 arcIdentifier = "ARC_ID"
@@ -65,7 +79,8 @@ func BillingMiddleware(next http.Handler) http.Handler {
6579}
6680
6781func getArcInstance (arcID string ) (ArcInstance , error ) {
68- response := ArcInstance {}
82+ arcInstance := ArcInstance {}
83+ response := []arcInstanceDetails {}
6984 url := ACC_API + "arc/instance?arcid=" + arcID
7085 req , _ := http .NewRequest ("GET" , url , nil )
7186 req .Header .Add ("Content-Type" , "application/json" )
@@ -75,23 +90,24 @@ func getArcInstance(arcID string) (ArcInstance, error) {
7590 fmt .Println ("Requesting:" , url )
7691 if err != nil {
7792 log .Println ("error while sending request: " , err )
78- return response , err
93+ return arcInstance , err
7994 }
8095 defer res .Body .Close ()
8196 body , err := ioutil .ReadAll (res .Body )
8297 fmt .Println ("bODY:" , body )
8398 if err != nil {
8499 log .Println ("error reading res body: " , err )
85- return response , err
100+ return arcInstance , err
86101 }
87102 err = json .Unmarshal (body , & response )
88103 fmt .Println ("RESPONSE:" , response )
104+ arcInstance .SubscriptionID = response [0 ].SubscriptionID
89105
90106 if err != nil {
91107 log .Println ("error while unmarshalling res body: " , err )
92- return response , err
108+ return arcInstance , err
93109 }
94- return response , nil
110+ return arcInstance , nil
95111}
96112
97113func ReportUsageRequest (arcUsage ArcUsage ) (ArcUsageResponse , error ) {
0 commit comments