Repository: cloudflare/cloudflare-go
Pull request #3758 (2024-12-19 17:22:16)

feat: make teams location params optional

github-actions[bot]: changelog detected :white_check_mark:
rexscaria: I will take *string
Thanks


*Rex Scaria | | ***@***.*** ***@***.***> |
+1-480-628-9203*



On Thu, Dec 19, 2024 at 8:29 PM Jacob Bednarz ***@***.***>
wrote:

> ***@***.**** commented on this pull request.
> ------------------------------
>
> In teams_locations.go
> <https://github.com/cloudflare/cloudflare-go/pull/3758#discussion_r1893323360>
> :
>
> > @@ -32,10 +32,10 @@ type TeamsLocation struct {
>  	Ip                        string                 `json:"ip,omitempty"`
>  	Subdomain                 string                 `json:"doh_subdomain"`
>  	AnonymizedLogsEnabled     bool                   `json:"anonymized_logs_enabled"`
> -	IPv4Destination           string                 `json:"ipv4_destination"`
> -	IPv4DestinationBackup     string                 `json:"ipv4_destination_backup"`
> -	DNSDestinationIPsID       string                 `json:"dns_destination_ips_id"`
> -	DNSDestinationIPv6BlockID string                 `json:"dns_destination_ipv6_block_id"`
> +	IPv4Destination           string                 `json:"ipv4_destination,omitempty"`
>
> do you want these to be *string to omit it entirely vs being empty?
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/cloudflare/cloudflare-go/pull/3758#pullrequestreview-2516520509>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAFN7RG57BBT2XWQCEIGSGD2GNXG5AVCNFSM6AAAAABT5OZWHKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMJWGUZDANJQHE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


Patch:
diff --git a/.changelog/3758.txt b/.changelog/3758.txt
new file mode 100644
index 000000000..2ab7e3829
--- /dev/null
+++ b/.changelog/3758.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+teams_location: make location parameters optional
+```
\ No newline at end of file
diff --git a/teams_locations.go b/teams_locations.go
index 489993a82..319f7c6c6 100644
--- a/teams_locations.go
+++ b/teams_locations.go
@@ -32,16 +32,15 @@ type TeamsLocation struct {
 	Ip                        string                  `json:"ip,omitempty"`
 	Subdomain                 string                  `json:"doh_subdomain"`
 	AnonymizedLogsEnabled     bool                    `json:"anonymized_logs_enabled"`
-	IPv4Destination           string                  `json:"ipv4_destination"`
-	IPv4DestinationBackup     string                  `json:"ipv4_destination_backup"`
-	DNSDestinationIPsID       string                  `json:"dns_destination_ips_id"`
-	DNSDestinationIPv6BlockID string                  `json:"dns_destination_ipv6_block_id"`
+	IPv4Destination           string                  `json:"ipv4_destination,omitempty"`
+	IPv4DestinationBackup     string                  `json:"ipv4_destination_backup,omitempty"`
+	DNSDestinationIPsID       *string                 `json:"dns_destination_ips_id,omitempty"`
+	DNSDestinationIPv6BlockID *string                 `json:"dns_destination_ipv6_block_id,omitempty"`
 	ClientDefault             bool                    `json:"client_default"`
 	ECSSupport                *bool                   `json:"ecs_support,omitempty"`
 	Endpoints                 *TeamsLocationEndpoints `json:"endpoints,omitempty"`
-
-	CreatedAt *time.Time `json:"created_at,omitempty"`
-	UpdatedAt *time.Time `json:"updated_at,omitempty"`
+	CreatedAt                 *time.Time              `json:"created_at,omitempty"`
+	UpdatedAt                 *time.Time              `json:"updated_at,omitempty"`
 }
 
 type TeamsLocationEndpoints struct {


Test patch:
diff --git a/teams_locations_test.go b/teams_locations_test.go
index 9acb094cf..b374c00ed 100644
--- a/teams_locations_test.go
+++ b/teams_locations_test.go
@@ -54,6 +54,8 @@ func TestTeamsLocations(t *testing.T) {
 	createdAt, _ := time.Parse(time.RFC3339, "2020-05-18T22:07:03Z")
 	updatedAt, _ := time.Parse(time.RFC3339, "2020-05-18T22:07:05Z")
 
+	ipv4Id := "9da8e0c9-e9cc-4bbd-85c5-b351fc373354"
+	ipv6Id := "8da8e0c9-e9cc-4bbd-85c5-b351fc373354"
 	want := []TeamsLocation{{
 		ID:                        "0f8185414dec4a5e9034f3d917c17890",
 		Name:                      "home",
@@ -63,8 +65,8 @@ func TestTeamsLocations(t *testing.T) {
 		AnonymizedLogsEnabled:     false,
 		IPv4Destination:           "1.2.3.4",
 		IPv4DestinationBackup:     "1.2.3.5",
-		DNSDestinationIPsID:       "9da8e0c9-e9cc-4bbd-85c5-b351fc373354",
-		DNSDestinationIPv6BlockID: "8da8e0c9-e9cc-4bbd-85c5-b351fc373354",
+		DNSDestinationIPsID:       &ipv4Id,
+		DNSDestinationIPv6BlockID: &ipv6Id,
 		ClientDefault:             false,
 		ECSSupport:                BoolPtr(false),
 		CreatedAt:                 &createdAt,