From 1800684e546e60baf08effca41cc95a49ada1003 Mon Sep 17 00:00:00 2001 From: kpdhulipala Date: Fri, 9 Feb 2024 12:09:27 -0800 Subject: [PATCH 1/2] project id filter on get accounts --- client.go | 9 +++++---- internal/api/account.go | 15 ++++++++------- rest_account.go | 11 ++++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/client.go b/client.go index ee51f85..6e2483d 100644 --- a/client.go +++ b/client.go @@ -230,10 +230,11 @@ func (e UpdateError) Error() string { // Account describes Network Edge customer account details type Account struct { - Name *string - Number *string - Status *string - UCMID *string + Name *string + Number *string + Status *string + UCMID *string + ProjectID *string } // Device describes Network Edge device diff --git a/internal/api/account.go b/internal/api/account.go index 37f63ac..8eb6b77 100644 --- a/internal/api/account.go +++ b/internal/api/account.go @@ -1,15 +1,16 @@ package api -//AccountResponse describes response to Network Edge -//billing account query +// AccountResponse describes response to Network Edge +// billing account query type AccountResponse struct { Accounts []Account `json:"accounts,omitempty"` } -//Account describes Network Edge billing account +// Account describes Network Edge billing account type Account struct { - Name *string `json:"accountName,omitempty"` - Number *string `json:"accountNumber,omitempty"` - UCMID *string `json:"accountUcmId,omitempty"` - Status *string `json:"accountStatus,omitempty"` + Name *string `json:"accountName,omitempty"` + Number *string `json:"accountNumber,omitempty"` + UCMID *string `json:"accountUcmId,omitempty"` + Status *string `json:"accountStatus,omitempty"` + ProjectID *string `json:"projectId,omitempty"` } diff --git a/rest_account.go b/rest_account.go index 1320834..ed61a2a 100644 --- a/rest_account.go +++ b/rest_account.go @@ -7,7 +7,7 @@ import ( "github.com/equinix/ne-go/internal/api" ) -//GetAccounts retrieves accounts and their details for a given metro code using Network Edge API +// GetAccounts retrieves accounts and their details for a given metro code using Network Edge API func (c RestClient) GetAccounts(metroCode string) ([]Account, error) { path := "/ne/v1/accounts/" + url.PathEscape(metroCode) respBody := api.AccountResponse{} @@ -23,10 +23,11 @@ func mapAccountsAPIToDomain(apiAccounts []api.Account) []Account { transformed := make([]Account, len(apiAccounts)) for i := range apiAccounts { transformed[i] = Account{ - Name: apiAccounts[i].Name, - Number: apiAccounts[i].Number, - UCMID: apiAccounts[i].UCMID, - Status: apiAccounts[i].Status, + Name: apiAccounts[i].Name, + Number: apiAccounts[i].Number, + UCMID: apiAccounts[i].UCMID, + Status: apiAccounts[i].Status, + ProjectID: apiAccounts[i].ProjectID, } } return transformed From 928bf72d79313eed86a53a93fe5f0687e5d704ce Mon Sep 17 00:00:00 2001 From: kpdhulipala Date: Fri, 9 Feb 2024 12:14:58 -0800 Subject: [PATCH 2/2] assertion for proj id --- rest_account_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/rest_account_test.go b/rest_account_test.go index 7126f1c..70b70c1 100644 --- a/rest_account_test.go +++ b/rest_account_test.go @@ -38,4 +38,5 @@ func verifyAccount(t *testing.T, apiAccount api.Account, account Account) { assert.Equal(t, apiAccount.Number, account.Number, "Account Number matches") assert.Equal(t, apiAccount.Status, account.Status, "Account Status matches") assert.Equal(t, apiAccount.UCMID, account.UCMID, "Account UCMID matches") + assert.Equal(t, apiAccount.ProjectID, account.ProjectID, "ProjectID matches") }