From 28f2098d8e2413320a1c92d170796acec160d057 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Mon, 9 Mar 2020 07:36:50 +1100 Subject: [PATCH 1/2] Update `*ListResponse` structs to match API responses When the work for terraform-providers/terraform-provider-cloudflare#597 was started, the `messages` object was either empty array or a single string (per the original `cloudflare.Response`[1] struct) but the API response is now spitting out an array of `message` objects inside of the current array. To fix the issue, the two structs have been updated to conform to the required objects. [1]: https://github.com/cloudflare/cloudflare-go/blob/master/cloudflare.go#L363 --- access_identity_provider.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/access_identity_provider.go b/access_identity_provider.go index 014e8b7f10e..92b12e4d5e3 100644 --- a/access_identity_provider.go +++ b/access_identity_provider.go @@ -45,19 +45,25 @@ type AccessIdentityProviderConfiguration struct { // AccessIdentityProvidersListResponse is the API response for multiple // Access Identity Providers. type AccessIdentityProvidersListResponse struct { - Success bool `json:"success"` - Errors []string `json:"errors"` - Messages []string `json:"messages"` - Result []AccessIdentityProvider `json:"result"` + Success bool `json:"success"` + Errors []string `json:"errors"` + Messages []AccessIdentityProviderMessages `json:"messages"` + Result []AccessIdentityProvider `json:"result"` } // AccessIdentityProviderListResponse is the API response for a single // Access Identity Provider. type AccessIdentityProviderListResponse struct { - Success bool `json:"success"` - Errors []string `json:"errors"` - Messages []string `json:"messages"` - Result AccessIdentityProvider `json:"result"` + Success bool `json:"success"` + Errors []string `json:"errors"` + Messages []AccessIdentityProviderMessages `json:"messages"` + Result AccessIdentityProvider `json:"result"` +} + +// AccessIdentityProviderMessages holds the API responses for any additional +// messages from the service. +type AccessIdentityProviderMessages struct { + Message string `json:"message"` } // AccessIdentityProviders returns all Access Identity Providers for an From 5f5ee32f8ee971f4681acb77b56b3bef88059860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Szczyg=C5=82owski?= Date: Mon, 9 Mar 2020 15:25:52 +0000 Subject: [PATCH 2/2] Use Response shared struct for handling fields --- access_identity_provider.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/access_identity_provider.go b/access_identity_provider.go index 92b12e4d5e3..f3018ec73aa 100644 --- a/access_identity_provider.go +++ b/access_identity_provider.go @@ -45,27 +45,17 @@ type AccessIdentityProviderConfiguration struct { // AccessIdentityProvidersListResponse is the API response for multiple // Access Identity Providers. type AccessIdentityProvidersListResponse struct { - Success bool `json:"success"` - Errors []string `json:"errors"` - Messages []AccessIdentityProviderMessages `json:"messages"` + Response Result []AccessIdentityProvider `json:"result"` } // AccessIdentityProviderListResponse is the API response for a single // Access Identity Provider. type AccessIdentityProviderListResponse struct { - Success bool `json:"success"` - Errors []string `json:"errors"` - Messages []AccessIdentityProviderMessages `json:"messages"` + Response Result AccessIdentityProvider `json:"result"` } -// AccessIdentityProviderMessages holds the API responses for any additional -// messages from the service. -type AccessIdentityProviderMessages struct { - Message string `json:"message"` -} - // AccessIdentityProviders returns all Access Identity Providers for an // account. //