Skip to content

Commit e11e6c1

Browse files
committed
Merge remote-tracking branch 'origin' into rex/update-teams-docs
2 parents 603f60f + e0e1dcd commit e11e6c1

File tree

10 files changed

+140
-89
lines changed

10 files changed

+140
-89
lines changed

.changelog/3742.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
certificate_authorities: fixes for methods to interact with Certificate Authorities Hostname Associations API
3+
```

.changelog/3756.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:dependency
2+
deps: bumps golang.org/x/net from 0.32.0 to 0.33.0
3+
```

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
## 0.112.0 (Unreleased)
1+
## 0.113.0 (Unreleased)
2+
3+
## 0.112.0 (December 18th, 2024)
4+
5+
ENHANCEMENTS:
6+
7+
* access_application: support Access service token + multi-valued authentication for SCIM provisioning ([#3708](https://github.com/cloudflare/cloudflare-go/issues/3708))
8+
* certificate_authorities: add new methods to interact with Certificate Authorities Hostname Associations API ([#3740](https://github.com/cloudflare/cloudflare-go/issues/3740))
9+
* content_scanning: Add new support for CRUD operations ([#3700](https://github.com/cloudflare/cloudflare-go/issues/3700))
10+
* teams: sync latest doc changes ([#3743](https://github.com/cloudflare/cloudflare-go/issues/3743))
11+
* teams_location: add support for `dns_destination_ipv6_block_id` to the location payload ([#3738](https://github.com/cloudflare/cloudflare-go/issues/3738))
12+
* teams_locations: Add dns_destination_ips_id and ipv4_destination_backup ([#3699](https://github.com/cloudflare/cloudflare-go/issues/3699))
13+
14+
BUG FIXES:
15+
16+
* certificate_authorities: fixes for methods to interact with Certificate Authorities Hostname Associations API ([#3742](https://github.com/cloudflare/cloudflare-go/issues/3742))
17+
18+
DEPENDENCIES:
19+
20+
* deps: bumps github.com/goccy/go-json from 0.10.3 to 0.10.4 ([#3726](https://github.com/cloudflare/cloudflare-go/issues/3726))
21+
* deps: bumps golang.org/x/crypto from 0.21.0 to 0.31.0 ([#3725](https://github.com/cloudflare/cloudflare-go/issues/3725))
22+
* deps: bumps golang.org/x/net from 0.31.0 to 0.32.0 ([#3704](https://github.com/cloudflare/cloudflare-go/issues/3704))
223

324
## 0.111.0 (December 4th, 2024)
425

certificate_authorities.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@ type UpdateCertificateAuthoritiesHostnameAssociationsParams struct {
1717
MTLSCertificateID string `json:"mtls_certificate_id,omitempty"`
1818
}
1919

20+
type HostnameAssociationsUpdateRequest struct {
21+
Hostnames []HostnameAssociation `json:"hostnames,omitempty"`
22+
MTLSCertificateID string `json:"mtls_certificate_id,omitempty"`
23+
}
24+
2025
type HostnameAssociationsResponse struct {
2126
Response
22-
Result []HostnameAssociation `json:"result"`
27+
Result HostnameAssociations `json:"result"`
28+
}
29+
30+
type HostnameAssociations struct {
31+
Hostnames []HostnameAssociation `json:"hostnames"`
2332
}
2433

2534
type HostnameAssociation = string
@@ -28,12 +37,11 @@ type HostnameAssociation = string
2837
//
2938
// API Reference: https://developers.cloudflare.com/api/resources/certificate_authorities/subresources/hostname_associations/methods/get/
3039
func (api *API) ListCertificateAuthoritiesHostnameAssociations(ctx context.Context, rc *ResourceContainer, params ListCertificateAuthoritiesHostnameAssociationsParams) ([]HostnameAssociation, error) {
40+
if rc.Level != ZoneRouteLevel {
41+
return []HostnameAssociation{}, ErrRequiredZoneLevelResourceContainer
42+
}
3143

32-
uri := fmt.Sprintf(
33-
"/%s/%s/certificate_authorities/hostname_associations",
34-
rc.Level,
35-
rc.Identifier,
36-
)
44+
uri := buildURI(fmt.Sprintf("/zones/%s/certificate_authorities/hostname_associations", rc.Identifier), params)
3745

3846
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
3947
if err != nil {
@@ -46,18 +54,18 @@ func (api *API) ListCertificateAuthoritiesHostnameAssociations(ctx context.Conte
4654
return []HostnameAssociation{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
4755
}
4856

49-
return hostnameAssociationsResponse.Result, nil
57+
return hostnameAssociationsResponse.Result.Hostnames, nil
5058
}
5159

5260
// Replace Hostname Associations
5361
//
5462
// API Reference: https://developers.cloudflare.com/api/resources/certificate_authorities/subresources/hostname_associations/methods/update/
5563
func (api *API) UpdateCertificateAuthoritiesHostnameAssociations(ctx context.Context, rc *ResourceContainer, params UpdateCertificateAuthoritiesHostnameAssociationsParams) ([]HostnameAssociation, error) {
56-
uri := fmt.Sprintf(
57-
"/%s/%s/certificate_authorities/hostname_associations",
58-
rc.Level,
59-
rc.Identifier,
60-
)
64+
if rc.Level != ZoneRouteLevel {
65+
return []HostnameAssociation{}, ErrRequiredZoneLevelResourceContainer
66+
}
67+
68+
uri := fmt.Sprintf("/zones/%s/certificate_authorities/hostname_associations", rc.Identifier)
6169

6270
res, err := api.makeRequestContext(ctx, http.MethodPut, uri, params)
6371
if err != nil {
@@ -70,5 +78,5 @@ func (api *API) UpdateCertificateAuthoritiesHostnameAssociations(ctx context.Con
7078
return []HostnameAssociation{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
7179
}
7280

73-
return hostnameAssociationsResponse.Result, nil
81+
return hostnameAssociationsResponse.Result.Hostnames, nil
7482
}

certificate_authorities_test.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"testing"
88

9+
"github.com/goccy/go-json"
910
"github.com/stretchr/testify/assert"
1011
)
1112

@@ -15,15 +16,18 @@ func TestListCertificateAuthoritiesHostnameAssociations(t *testing.T) {
1516

1617
handler := func(w http.ResponseWriter, r *http.Request) {
1718
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
19+
assert.Equal(t, "72ef4d06-4752-4493-a60a-7421470fd585", r.URL.Query().Get("mtls_certificate_id"))
1820
w.Header().Set("content-type", "application/json")
1921
fmt.Fprintf(w, `{
2022
"success": true,
2123
"errors": [],
2224
"messages": [],
23-
"result": [
24-
"admin.example.com",
25-
"foobar.example.com"
26-
]
25+
"result": {
26+
"hostnames": [
27+
"admin.example.com",
28+
"foobar.example.com"
29+
]
30+
}
2731
}`)
2832
}
2933

@@ -51,19 +55,32 @@ func TestUpdateCertificateAuthoritiesHostnameAssociations(t *testing.T) {
5155

5256
handler := func(w http.ResponseWriter, r *http.Request) {
5357
assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
58+
59+
wantReqHostnames := []HostnameAssociation{
60+
"admin.example.com",
61+
"foobar.example.com",
62+
}
63+
var req HostnameAssociationsUpdateRequest
64+
assert.NoError(t, json.NewDecoder(r.Body).Decode(&req))
65+
assert.Equal(t, "72ef4d06-4752-4493-a60a-7421470fd585", req.MTLSCertificateID)
66+
assert.Equal(t, wantReqHostnames, req.Hostnames)
67+
5468
w.Header().Set("content-type", "application/json")
5569
fmt.Fprintf(w, `{
5670
"success": true,
5771
"errors": [],
5872
"messages": [],
59-
"result": [
60-
"admin.example.com",
61-
"foobar.example.com"
62-
]
73+
"result": {
74+
"hostnames": [
75+
"admin.example.com",
76+
"foobar.example.com"
77+
]
78+
}
6379
}`)
6480
}
6581

6682
hostnameAssociations := UpdateCertificateAuthoritiesHostnameAssociationsParams{
83+
MTLSCertificateID: "72ef4d06-4752-4493-a60a-7421470fd585",
6784
Hostnames: []HostnameAssociation{
6885
"admin.example.com",
6986
"foobar.example.com",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/olekukonko/tablewriter v0.0.5
99
github.com/stretchr/testify v1.10.0
1010
github.com/urfave/cli/v2 v2.27.5
11-
golang.org/x/net v0.32.0
11+
golang.org/x/net v0.33.0
1212
golang.org/x/time v0.8.0
1313
)
1414

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
3939
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
4040
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
4141
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
42-
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
43-
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
42+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
43+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
4444
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
4545
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
4646
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=

teams_accounts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ type TeamsAccountSettings struct {
5050
ExtendedEmailMatching *TeamsExtendedEmailMatching `json:"extended_email_matching,omitempty"`
5151
CustomCertificate *TeamsCustomCertificate `json:"custom_certificate,omitempty"`
5252
Certificate *TeamsCertificateSetting `json:"certificate,omitempty"`
53-
Sandbox *SandboxAccountSetting `json:"sandbox,omitempty"`
53+
Sandbox *TeamsSandboxAccountSetting `json:"sandbox,omitempty"`
5454
}
5555

56-
type SandboxAccountSetting struct {
56+
type TeamsSandboxAccountSetting struct {
5757
Enabled *bool `db:"enabled" json:"enabled" validate:"required"`
5858
FallbackAction string `db:"fallback_action" json:"fallback_action" validate:"omitempty,oneof=allow block"`
5959
}

teams_locations.go

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,50 @@ type TeamsLocationNetwork struct {
2626
}
2727

2828
type TeamsLocation struct {
29-
ID string `json:"id"`
30-
Name string `json:"name"`
31-
Networks []TeamsLocationNetwork `json:"networks"`
32-
Ip string `json:"ip,omitempty"`
33-
Subdomain string `json:"doh_subdomain"`
34-
AnonymizedLogsEnabled bool `json:"anonymized_logs_enabled"`
35-
IPv4Destination string `json:"ipv4_destination,omitempty"`
36-
IPv4DestinationBackup string `json:"ipv4_destination_backup,omitempty"`
37-
DNSDestinationIPsID *string `json:"dns_destination_ips_id,omitempty"`
38-
DNSDestinationIPv6BlockID *string `json:"dns_destination_ipv6_block_id,omitempty"`
39-
ClientDefault bool `json:"client_default"`
40-
ECSSupport *bool `json:"ecs_support,omitempty"`
41-
Endpoints *LocationEndpoints `json:"endpoints,omitempty"`
42-
43-
CreatedAt *time.Time `json:"created_at,omitempty"`
44-
UpdatedAt *time.Time `json:"updated_at,omitempty"`
29+
ID string `json:"id"`
30+
Name string `json:"name"`
31+
Networks []TeamsLocationNetwork `json:"networks"`
32+
Ip string `json:"ip,omitempty"`
33+
Subdomain string `json:"doh_subdomain"`
34+
AnonymizedLogsEnabled bool `json:"anonymized_logs_enabled"`
35+
IPv4Destination string `json:"ipv4_destination,omitempty"`
36+
IPv4DestinationBackup string `json:"ipv4_destination_backup,omitempty"`
37+
DNSDestinationIPsID *string `json:"dns_destination_ips_id,omitempty"`
38+
DNSDestinationIPv6BlockID *string `json:"dns_destination_ipv6_block_id,omitempty"`
39+
ClientDefault bool `json:"client_default"`
40+
ECSSupport *bool `json:"ecs_support,omitempty"`
41+
Endpoints *TeamsLocationEndpoints `json:"endpoints,omitempty"`
42+
CreatedAt *time.Time `json:"created_at,omitempty"`
43+
UpdatedAt *time.Time `json:"updated_at,omitempty"`
4544
}
4645

47-
type LocationEndpoints struct {
48-
IPv4Endpoint IPv4EndpointFields `json:"ipv4"`
49-
IPv6Endpoint IPv6EndpointFields `json:"ipv6"`
50-
DotEndpoint DotEndpointFields `json:"dot"`
51-
DohEndpoint DohEndpointFields `json:"doh"`
46+
type TeamsLocationEndpoints struct {
47+
IPv4Endpoint TeamsLocationIPv4EndpointFields `json:"ipv4"`
48+
IPv6Endpoint TeamsLocationIPv6EndpointFields `json:"ipv6"`
49+
DotEndpoint TeamsLocationDotEndpointFields `json:"dot"`
50+
DohEndpoint TeamsLocationDohEndpointFields `json:"doh"`
5251
}
5352

54-
type IPv4EndpointFields struct {
53+
type TeamsLocationIPv4EndpointFields struct {
5554
Enabled bool `json:"enabled"`
5655
AuthenticationEnabled bool `json:"authentication_enabled,omitempty"`
5756
}
5857

59-
type IPv6EndpointFields struct {
60-
EndpointFields
58+
type TeamsLocationIPv6EndpointFields struct {
59+
TeamsLocationEndpointFields
6160
}
6261

63-
type DotEndpointFields struct {
62+
type TeamsLocationDotEndpointFields struct {
6463
RequireToken bool `json:"require_token"`
65-
EndpointFields
64+
TeamsLocationEndpointFields
6665
}
6766

68-
type DohEndpointFields struct {
67+
type TeamsLocationDohEndpointFields struct {
6968
RequireToken bool `json:"require_token"`
70-
EndpointFields
69+
TeamsLocationEndpointFields
7170
}
7271

73-
type EndpointFields struct {
72+
type TeamsLocationEndpointFields struct {
7473
Enabled bool `json:"enabled"`
7574
AuthenticationEnabledUIHelper bool `json:"authentication_enabled,omitempty"`
7675
Networks []TeamsLocationNetwork `json:"networks,omitempty"`

teams_rules.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ type TeamsRuleSettings struct {
6868
DnsResolverSettings *TeamsDnsResolverSettings `json:"dns_resolvers,omitempty"`
6969

7070
NotificationSettings *TeamsNotificationSettings `json:"notification_settings"`
71-
Quarantine *Quarantine `json:"quarantine,omitempty"`
72-
ForensicCopySettings *ForensicCopySettings `json:"forensic_copy,omitempty"`
71+
Quarantine *TeamsQuarantine `json:"quarantine,omitempty"`
72+
ForensicCopySettings *TeamsForensicCopySettings `json:"forensic_copy,omitempty"`
7373
}
7474

75-
type ForensicCopySettings struct {
75+
type TeamsForensicCopySettings struct {
7676
Enabled bool `json:"enabled"`
7777
}
7878

79-
type Quarantine struct {
79+
type TeamsQuarantine struct {
8080
FileTypes []FileType `json:"file_types"`
8181
}
8282

@@ -216,43 +216,43 @@ func TeamsRulesUntrustedCertActionValues() []string {
216216

217217
// TeamsRule represents an Teams wirefilter rule.
218218
type TeamsRule struct {
219-
ID string `json:"id,omitempty"`
220-
CreatedAt *time.Time `json:"created_at,omitempty"`
221-
UpdatedAt *time.Time `json:"updated_at,omitempty"`
222-
DeletedAt *time.Time `json:"deleted_at,omitempty"`
223-
Name string `json:"name"`
224-
Description string `json:"description"`
225-
Precedence uint64 `json:"precedence"`
226-
Enabled bool `json:"enabled"`
227-
Action TeamsGatewayAction `json:"action"`
228-
Filters []TeamsFilterType `json:"filters"`
229-
Traffic string `json:"traffic"`
230-
Identity string `json:"identity"`
231-
DevicePosture string `json:"device_posture"`
232-
Version uint64 `json:"version"`
233-
RuleSettings TeamsRuleSettings `json:"rule_settings,omitempty"`
234-
Schedule *RuleSchedule `json:"schedule,omitempty"` // only available at DNS rules
235-
Expiration *RuleExpiration `json:"expiration,omitempty"` // only available at DNS rules
219+
ID string `json:"id,omitempty"`
220+
CreatedAt *time.Time `json:"created_at,omitempty"`
221+
UpdatedAt *time.Time `json:"updated_at,omitempty"`
222+
DeletedAt *time.Time `json:"deleted_at,omitempty"`
223+
Name string `json:"name"`
224+
Description string `json:"description"`
225+
Precedence uint64 `json:"precedence"`
226+
Enabled bool `json:"enabled"`
227+
Action TeamsGatewayAction `json:"action"`
228+
Filters []TeamsFilterType `json:"filters"`
229+
Traffic string `json:"traffic"`
230+
Identity string `json:"identity"`
231+
DevicePosture string `json:"device_posture"`
232+
Version uint64 `json:"version"`
233+
RuleSettings TeamsRuleSettings `json:"rule_settings,omitempty"`
234+
Schedule *TeamsRuleSchedule `json:"schedule,omitempty"` // only available at DNS rules
235+
Expiration *TeamsRuleExpiration `json:"expiration,omitempty"` // only available at DNS rules
236236
}
237237

238-
type RuleExpiration struct {
238+
type TeamsRuleExpiration struct {
239239
ExpiresAt *time.Time `json:"expires_at"`
240240
Duration *uint64 `json:"duration,omitempty"` // read only
241241
Expired bool `json:"expired"` // read only
242242
}
243243

244244
// format HH:MM,HH:MM,....,HH:MM
245-
type ScheduleTimes string
246-
247-
type RuleSchedule struct {
248-
Monday ScheduleTimes `json:"mon,omitempty"`
249-
Tuesday ScheduleTimes `json:"tue,omitempty"`
250-
Wednesday ScheduleTimes `json:"wed,omitempty"`
251-
Thursday ScheduleTimes `json:"thu,omitempty"`
252-
Friday ScheduleTimes `json:"fri,omitempty"`
253-
Saturday ScheduleTimes `json:"sat,omitempty"`
254-
Sunday ScheduleTimes `json:"sun,omitempty"`
255-
TimeZone string `json:"time_zone,omitempty"` // default to user TZ based on the user IP location, fall backs to colo TZ
245+
type TeamsScheduleTimes string
246+
247+
type TeamsRuleSchedule struct {
248+
Monday TeamsScheduleTimes `json:"mon,omitempty"`
249+
Tuesday TeamsScheduleTimes `json:"tue,omitempty"`
250+
Wednesday TeamsScheduleTimes `json:"wed,omitempty"`
251+
Thursday TeamsScheduleTimes `json:"thu,omitempty"`
252+
Friday TeamsScheduleTimes `json:"fri,omitempty"`
253+
Saturday TeamsScheduleTimes `json:"sat,omitempty"`
254+
Sunday TeamsScheduleTimes `json:"sun,omitempty"`
255+
TimeZone string `json:"time_zone,omitempty"` // default to user TZ based on the user IP location, fall backs to colo TZ
256256
}
257257

258258
// TeamsRuleResponse is the API response, containing a single rule.

0 commit comments

Comments
 (0)