Repository: cloudflare/cloudflare-go (go)

Issue:
Zone: missing VerificationKey field 
Hello,

for enterprise customers deciding to create zones with the `partial` type (to use external DNS), the newly created `Zone` has an additional field `verification_key`. It wuold be great to add the field to the type to consume it elsewhere.

## Expected behavior

When calling `ListZones()` I would expect the enterprise zones to have `verficiation_key` field exported.

## Current behavior

The field is not present in `ZoneResponse.Zone`.

## Possible solution

add `VerificationKey` exported field in https://github.com/cloudflare/cloudflare-go/blob/c70f6a08eddbafee3dda58e9fab8302a1ea31d75/zone.go#L24 

## Context

This is useful in Terraform provider to read the activation key directly from the API and act on the external DNS provider.

## References

https://github.com/terraform-providers/terraform-provider-cloudflare/issues/280#issuecomment-537220861

## Your Environment

Enterprise account



Pull request:
adding VerificationKey field to Zone for enterprise customers
## Description

Fixes #353 

## Has your change been tested?

Unit tests...

## Types of changes

What sort of change does your code introduce/modify?

- [X] New feature (non-breaking change which adds functionality): added `VerificationKey` to `Zone`

## Checklist:

- [X] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [X] I have added tests to cover my changes.
- [X] All new and existing tests passed.



Patch:
diff --git a/go.mod b/go.mod
index 434554760..1b23e0aba 100644
--- a/go.mod
+++ b/go.mod
@@ -9,6 +9,6 @@ require (
 	github.com/pkg/errors v0.8.1
 	github.com/stretchr/testify v1.4.0
 	github.com/urfave/cli v1.22.1
-	golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3
+	golang.org/x/net v0.0.0-20191002035440-2ec189313ef0
 	golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0
 )
diff --git a/go.sum b/go.sum
index e0101bafe..fb3be74bd 100644
--- a/go.sum
+++ b/go.sum
@@ -26,6 +26,8 @@ golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD
 golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3 h1:6KET3Sqa7fkVfD63QnAM81ZeYg5n4HwApOJkufONnHA=
 golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 h1:2mqDk8w/o6UmeUCu5Qiq2y7iMf6anbx+YA8d1JFoFrs=
+golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
diff --git a/vendor/modules.txt b/vendor/modules.txt
index e21f3bb31..d9fc18561 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -18,7 +18,7 @@ github.com/shurcooL/sanitized_anchor_name
 github.com/stretchr/testify/assert
 # github.com/urfave/cli v1.22.1
 github.com/urfave/cli
-# golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3
+# golang.org/x/net v0.0.0-20191002035440-2ec189313ef0
 golang.org/x/net/idna
 # golang.org/x/text v0.3.0
 golang.org/x/text/secure/bidirule
diff --git a/zone.go b/zone.go
index 59fda9e46..ddf384853 100644
--- a/zone.go
+++ b/zone.go
@@ -49,6 +49,7 @@ type Zone struct {
 	DeactReason string   `json:"deactivation_reason"`
 	Meta        ZoneMeta `json:"meta"`
 	Account     Account  `json:"account"`
+	VerificationKey string `json:"verification_key"`
 }
 
 // ZoneMeta describes metadata about a zone.
@@ -139,7 +140,7 @@ type ZoneRatePlanResponse struct {
 type ZoneSetting struct {
 	ID            string      `json:"id"`
 	Editable      bool        `json:"editable"`
-	ModifiedOn    string      `json:"modified_on"`
+	ModifiedOn    string      `json:"modified_on,omitempty"`
 	Value         interface{} `json:"value"`
 	TimeRemaining int         `json:"time_remaining"`
 }


Test patch:
diff --git a/zone_test.go b/zone_test.go
index 1bc9fb6b1..eca799c77 100644
--- a/zone_test.go
+++ b/zone_test.go
@@ -992,3 +992,107 @@ func Test_normalizeZoneName(t *testing.T) {
 		})
 	}
 }
+
+func TestZonePartialHasVerificationKey(t *testing.T) {
+	setup()
+	defer teardown()
+
+	handler := func(w http.ResponseWriter, r *http.Request) {
+		assert.Equal(t, "GET", r.Method, "Expected method 'GET', got %s", r.Method)
+
+		w.Header().Set("content-type", "application/json")
+		// JSON data from: https://api.cloudflare.com/#zone-zone-details (plus an undocumented field verification_key from curl to API)
+		fmt.Fprintf(w, `{
+  "result": {
+    "id": "foo",
+    "name": "bar",
+    "status": "active",
+    "paused": false,
+    "type": "partial",
+    "development_mode": 0,
+    "verification_key": "foo-bar",
+    "original_name_servers": ["a","b","c","d"],
+    "original_registrar": null,
+    "original_dnshost": null,
+    "modified_on": "2019-09-04T15:11:43.409805Z",
+    "created_on": "2018-12-06T14:33:38.410126Z",
+    "activated_on": "2018-12-06T14:34:39.274528Z",
+    "meta": {
+      "step": 4,
+      "wildcard_proxiable": true,
+      "custom_certificate_quota": 1,
+      "page_rule_quota": 100,
+      "phishing_detected": false,
+      "multiple_railguns_allowed": false
+    },
+    "owner": {
+      "id": "bbbbbbbbbbbbbbbbbbbbbbbb",
+      "type": "organization",
+      "name": "OrgName"
+    },
+    "account": {
+      "id": "aaaaaaaaaaaaaaaaaaaaaaaa",
+      "name": "AccountName"
+    },
+    "permissions": [
+      "#access:edit",
+      "#access:read",
+      "#analytics:read",
+      "#app:edit",
+      "#auditlogs:read",
+      "#billing:read",
+      "#cache_purge:edit",
+      "#dns_records:edit",
+      "#dns_records:read",
+      "#lb:edit",
+      "#lb:read",
+      "#legal:read",
+      "#logs:edit",
+      "#logs:read",
+      "#member:read",
+      "#organization:edit",
+      "#organization:read",
+      "#ssl:edit",
+      "#ssl:read",
+      "#stream:edit",
+      "#stream:read",
+      "#subscription:edit",
+      "#subscription:read",
+      "#waf:edit",
+      "#waf:read",
+      "#webhooks:edit",
+      "#webhooks:read",
+      "#worker:edit",
+      "#worker:read",
+      "#zone:edit",
+      "#zone:read",
+      "#zone_settings:edit",
+      "#zone_settings:read"
+    ],
+    "plan": {
+      "id": "94f3b7b768b0458b56d2cac4fe5ec0f9",
+      "name": "Enterprise Website",
+      "price": 0,
+      "currency": "USD",
+      "frequency": "monthly",
+      "is_subscribed": true,
+      "can_subscribe": true,
+      "legacy_id": "enterprise",
+      "legacy_discount": false,
+      "externally_managed": true
+    }
+  },
+  "success": true,
+  "errors": [],
+  "messages": []
+}`)
+	}
+
+	mux.HandleFunc("/zones/foo", handler)
+
+	z, err := client.ZoneDetails("foo")
+	if assert.NoError(t, err) {
+		assert.NotEmpty(t, z.VerificationKey)
+		assert.Equal(t, z.VerificationKey,"foo-bar")
+	}
+}