Skip to content

Commit

Permalink
Merge branch 'master' into dharper/APISHI-2353
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz authored Sep 12, 2023
2 parents 0e8b154 + f968533 commit 3774a56
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/1384.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
dcv_delegation: add GET for DCV Delegation UUID
```
3 changes: 3 additions & 0 deletions .changelog/1396.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:dependency
deps: bumps goreleaser/goreleaser-action from 4.6.0 to 5.0.0
```
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4.6.0
uses: goreleaser/goreleaser-action@v5.0.0
with:
version: latest
args: release --rm-dist
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## 0.77.0 (Unreleased)
## 0.78.0 (Unreleased)

## 0.77.0 (September 13th, 2023)

ENHANCEMENTS:

* access_identity_provider: add support for email_claim_name and authorization_server_id ([#1390](https://github.com/cloudflare/cloudflare-go/issues/1390))
* access_identity_provider: add support for ping_env_id ([#1391](https://github.com/cloudflare/cloudflare-go/issues/1391))
* dcv_delegation: add GET for DCV Delegation UUID ([#1384](https://github.com/cloudflare/cloudflare-go/issues/1384))
* streams: adds support to initiate tus upload ([#1359](https://github.com/cloudflare/cloudflare-go/issues/1359))
* tunnel: add support for `include_prefix`, `exclude_prefix` in list operations ([#1385](https://github.com/cloudflare/cloudflare-go/issues/1385))

Expand All @@ -16,6 +19,7 @@ DEPENDENCIES:
* deps: bumps actions/checkout from 3 to 4 ([#1387](https://github.com/cloudflare/cloudflare-go/issues/1387))
* deps: bumps golang.org/x/net from 0.14.0 to 0.15.0 ([#1389](https://github.com/cloudflare/cloudflare-go/issues/1389))
* deps: bumps goreleaser/goreleaser-action from 4.4.0 to 4.6.0 ([#1388](https://github.com/cloudflare/cloudflare-go/issues/1388))
* deps: bumps goreleaser/goreleaser-action from 4.6.0 to 5.0.0 ([#1396](https://github.com/cloudflare/cloudflare-go/issues/1396))

## 0.76.0 (August 30th, 2023)

Expand Down
41 changes: 41 additions & 0 deletions dcv_delegation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cloudflare

import (
"context"
"fmt"
"net/http"

"github.com/goccy/go-json"
)

type DCVDelegation struct {
UUID string `json:"uuid"`
}

// DCVDelegationResponse represents the response from the dcv_delegation/uuid endpoint.
type DCVDelegationResponse struct {
Result DCVDelegation `json:"result"`
Response
ResultInfo `json:"result_info"`
}

type GetDCVDelegationParams struct{}

// GetDCVDelegation gets a zone DCV Delegation UUID.
//
// API documentation: https://developers.cloudflare.com/api/operations/dcv-delegation-uuid-get
func (api *API) GetDCVDelegation(ctx context.Context, rc *ResourceContainer, params GetDCVDelegationParams) (DCVDelegation, ResultInfo, error) {
uri := fmt.Sprintf("/zones/%s/dcv_delegation/uuid", rc.Identifier)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return DCVDelegation{}, ResultInfo{}, err
}
var dcvResponse DCVDelegationResponse
err = json.Unmarshal(res, &dcvResponse)
if err != nil {
return DCVDelegation{}, ResultInfo{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
}

return dcvResponse.Result, dcvResponse.ResultInfo, nil
}
43 changes: 43 additions & 0 deletions dcv_delegation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cloudflare

import (
"context"
"fmt"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetDCVDelegation(t *testing.T) {
setup()
defer teardown()

testUuid := "b9ab465427f949ed"

handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, `{
"success" : true,
"errors": [],
"messages": [],
"result": {
"uuid": "%s"
}
}
`, testUuid)
}

mux.HandleFunc("/zones/"+testZoneID+"/dcv_delegation/uuid", handler)

want := DCVDelegation{
UUID: testUuid,
}

actual, _, err := client.GetDCVDelegation(context.Background(), ZoneIdentifier(testZoneID), GetDCVDelegationParams{})

if assert.NoError(t, err) {
assert.Equal(t, want, actual)
}
}

0 comments on commit 3774a56

Please sign in to comment.