Repository: cloudflare/cloudflare-go
Pull request #3743 (2024-12-17 16:40:05)

feat: sync teams gateway docs
This PR syncs some new gateway fields


Patch:
diff --git a/.changelog/3743.txt b/.changelog/3743.txt
new file mode 100644
index 000000000..f332a5391
--- /dev/null
+++ b/.changelog/3743.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+teams: sync latest doc changes
+```
\ No newline at end of file
diff --git a/teams_accounts.go b/teams_accounts.go
index 051f9dcb6..deaa96a00 100644
--- a/teams_accounts.go
+++ b/teams_accounts.go
@@ -10,9 +10,11 @@ import (
 )
 
 type TeamsAccount struct {
-	GatewayTag   string `json:"gateway_tag"`   // Internal teams ID
-	ProviderName string `json:"provider_name"` // Auth provider
-	ID           string `json:"id"`            // cloudflare account ID
+	GatewayTag      string `json:"gateway_tag"`                 // Internal teams ID
+	ProviderName    string `json:"provider_name"`               // Auth provider
+	ID              string `json:"id"`                          // cloudflare account ID
+	TenantAccountID string `json:"tenant_account_id,omitempty"` // cloudflare Tenant account ID, if a tenant account
+	TenantID        string `json:"tenant_id,omitempty"`         // cloudflare Tenant ID, if a tenant account id
 }
 
 // TeamsAccountResponse is the API response, containing information on teams
@@ -48,6 +50,12 @@ type TeamsAccountSettings struct {
 	ExtendedEmailMatching *TeamsExtendedEmailMatching `json:"extended_email_matching,omitempty"`
 	CustomCertificate     *TeamsCustomCertificate     `json:"custom_certificate,omitempty"`
 	Certificate           *TeamsCertificateSetting    `json:"certificate,omitempty"`
+	Sandbox               *TeamsSandboxAccountSetting `json:"sandbox,omitempty"`
+}
+
+type TeamsSandboxAccountSetting struct {
+	Enabled        *bool  `db:"enabled" json:"enabled" validate:"required"`
+	FallbackAction string `db:"fallback_action" json:"fallback_action" validate:"omitempty,oneof=allow block"`
 }
 
 type BrowserIsolation struct {
diff --git a/teams_audit_ssh_settings.go b/teams_audit_ssh_settings.go
index a4ec1e320..bad239355 100644
--- a/teams_audit_ssh_settings.go
+++ b/teams_audit_ssh_settings.go
@@ -11,10 +11,11 @@ import (
 
 // TeamsList represents a Teams List.
 type AuditSSHSettings struct {
-	PublicKey string     `json:"public_key"`
-	SeedUUID  string     `json:"seed_id"`
-	CreatedAt *time.Time `json:"created_at"`
-	UpdatedAt *time.Time `json:"updated_at"`
+	PublicKey        string     `json:"public_key"`
+	SeedUUID         string     `json:"seed_id"`
+	IsPublicKeyValid bool       `json:"is_public_key_valid,omitempty"`
+	CreatedAt        *time.Time `json:"created_at"`
+	UpdatedAt        *time.Time `json:"updated_at"`
 }
 
 type AuditSSHSettingsResponse struct {
diff --git a/teams_locations.go b/teams_locations.go
index c15ff4552..489993a82 100644
--- a/teams_locations.go
+++ b/teams_locations.go
@@ -26,24 +26,56 @@ type TeamsLocationNetwork struct {
 }
 
 type TeamsLocation struct {
-	ID                        string                 `json:"id"`
-	Name                      string                 `json:"name"`
-	Networks                  []TeamsLocationNetwork `json:"networks"`
-	PolicyIDs                 []string               `json:"policy_ids"`
-	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"`
-	ClientDefault             bool                   `json:"client_default"`
-	ECSSupport                *bool                  `json:"ecs_support,omitempty"`
+	ID                        string                  `json:"id"`
+	Name                      string                  `json:"name"`
+	Networks                  []TeamsLocationNetwork  `json:"networks"`
+	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"`
+	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"`
 }
 
+type TeamsLocationEndpoints struct {
+	IPv4Endpoint TeamsLocationIPv4EndpointFields `json:"ipv4"`
+	IPv6Endpoint TeamsLocationIPv6EndpointFields `json:"ipv6"`
+	DotEndpoint  TeamsLocationDotEndpointFields  `json:"dot"`
+	DohEndpoint  TeamsLocationDohEndpointFields  `json:"doh"`
+}
+
+type TeamsLocationIPv4EndpointFields struct {
+	Enabled               bool `json:"enabled"`
+	AuthenticationEnabled bool `json:"authentication_enabled,omitempty"`
+}
+
+type TeamsLocationIPv6EndpointFields struct {
+	TeamsLocationEndpointFields
+}
+
+type TeamsLocationDotEndpointFields struct {
+	RequireToken bool `json:"require_token"`
+	TeamsLocationEndpointFields
+}
+
+type TeamsLocationDohEndpointFields struct {
+	RequireToken bool `json:"require_token"`
+	TeamsLocationEndpointFields
+}
+
+type TeamsLocationEndpointFields struct {
+	Enabled                       bool                   `json:"enabled"`
+	AuthenticationEnabledUIHelper bool                   `json:"authentication_enabled,omitempty"`
+	Networks                      []TeamsLocationNetwork `json:"networks,omitempty"`
+}
+
 // TeamsLocations returns all locations within an account.
 //
 // API reference: https://api.cloudflare.com/#teams-locations-list-teams-locations
diff --git a/teams_rules.go b/teams_rules.go
index 38bfbcec0..c4b8e5d86 100644
--- a/teams_rules.go
+++ b/teams_rules.go
@@ -68,8 +68,20 @@ type TeamsRuleSettings struct {
 	DnsResolverSettings *TeamsDnsResolverSettings `json:"dns_resolvers,omitempty"`
 
 	NotificationSettings *TeamsNotificationSettings `json:"notification_settings"`
+	Quarantine           *TeamsQuarantine           `json:"quarantine,omitempty"`
+	ForensicCopySettings *TeamsForensicCopySettings `json:"forensic_copy,omitempty"`
 }
 
+type TeamsForensicCopySettings struct {
+	Enabled bool `json:"enabled"`
+}
+
+type TeamsQuarantine struct {
+	FileTypes []FileType `json:"file_types"`
+}
+
+type FileType = string
+
 type TeamsGatewayUntrustedCertAction string
 
 const (
@@ -204,21 +216,43 @@ func TeamsRulesUntrustedCertActionValues() []string {
 
 // TeamsRule represents an Teams wirefilter rule.
 type TeamsRule struct {
-	ID            string             `json:"id,omitempty"`
-	CreatedAt     *time.Time         `json:"created_at,omitempty"`
-	UpdatedAt     *time.Time         `json:"updated_at,omitempty"`
-	DeletedAt     *time.Time         `json:"deleted_at,omitempty"`
-	Name          string             `json:"name"`
-	Description   string             `json:"description"`
-	Precedence    uint64             `json:"precedence"`
-	Enabled       bool               `json:"enabled"`
-	Action        TeamsGatewayAction `json:"action"`
-	Filters       []TeamsFilterType  `json:"filters"`
-	Traffic       string             `json:"traffic"`
-	Identity      string             `json:"identity"`
-	DevicePosture string             `json:"device_posture"`
-	Version       uint64             `json:"version"`
-	RuleSettings  TeamsRuleSettings  `json:"rule_settings,omitempty"`
+	ID            string               `json:"id,omitempty"`
+	CreatedAt     *time.Time           `json:"created_at,omitempty"`
+	UpdatedAt     *time.Time           `json:"updated_at,omitempty"`
+	DeletedAt     *time.Time           `json:"deleted_at,omitempty"`
+	Name          string               `json:"name"`
+	Description   string               `json:"description"`
+	Precedence    uint64               `json:"precedence"`
+	Enabled       bool                 `json:"enabled"`
+	Action        TeamsGatewayAction   `json:"action"`
+	Filters       []TeamsFilterType    `json:"filters"`
+	Traffic       string               `json:"traffic"`
+	Identity      string               `json:"identity"`
+	DevicePosture string               `json:"device_posture"`
+	Version       uint64               `json:"version"`
+	RuleSettings  TeamsRuleSettings    `json:"rule_settings,omitempty"`
+	Schedule      *TeamsRuleSchedule   `json:"schedule,omitempty"`   // only available at DNS rules
+	Expiration    *TeamsRuleExpiration `json:"expiration,omitempty"` // only available at DNS rules
+}
+
+type TeamsRuleExpiration struct {
+	ExpiresAt *time.Time `json:"expires_at"`
+	Duration  *uint64    `json:"duration,omitempty"` // read only
+	Expired   bool       `json:"expired"`            // read only
+}
+
+// format HH:MM,HH:MM,....,HH:MM
+type TeamsScheduleTimes string
+
+type TeamsRuleSchedule struct {
+	Monday    TeamsScheduleTimes `json:"mon,omitempty"`
+	Tuesday   TeamsScheduleTimes `json:"tue,omitempty"`
+	Wednesday TeamsScheduleTimes `json:"wed,omitempty"`
+	Thursday  TeamsScheduleTimes `json:"thu,omitempty"`
+	Friday    TeamsScheduleTimes `json:"fri,omitempty"`
+	Saturday  TeamsScheduleTimes `json:"sat,omitempty"`
+	Sunday    TeamsScheduleTimes `json:"sun,omitempty"`
+	TimeZone  string             `json:"time_zone,omitempty"` // default to user TZ based on the user IP location, fall backs to colo TZ
 }
 
 // TeamsRuleResponse is the API response, containing a single rule.


Test patch:
diff --git a/teams_locations_test.go b/teams_locations_test.go
index 1c5c255c5..9acb094cf 100644
--- a/teams_locations_test.go
+++ b/teams_locations_test.go
@@ -58,7 +58,6 @@ func TestTeamsLocations(t *testing.T) {
 		ID:                        "0f8185414dec4a5e9034f3d917c17890",
 		Name:                      "home",
 		Networks:                  []TeamsLocationNetwork{{ID: "8e4c7835436345f0ab395429b187a076", Network: "198.51.100.1/32"}},
-		PolicyIDs:                 []string{},
 		Ip:                        "2a06:98c1:54::2419",
 		Subdomain:                 "q15l7x2lbw",
 		AnonymizedLogsEnabled:     false,
@@ -121,7 +120,6 @@ func TestTeamsLocation(t *testing.T) {
 		ID:                    id,
 		Name:                  "home",
 		Networks:              []TeamsLocationNetwork{{ID: "8e4c7835436345f0ab395429b187a076", Network: "198.51.100.1/32"}},
-		PolicyIDs:             []string{},
 		Ip:                    "2a06:98c1:54::2419",
 		Subdomain:             "q15l7x2lbw",
 		AnonymizedLogsEnabled: false,
@@ -181,7 +179,6 @@ func TestCreateTeamsLocation(t *testing.T) {
 		ID:                    id,
 		Name:                  "test",
 		Networks:              []TeamsLocationNetwork{{ID: "8e4c7835436345f0ab395429b187a076", Network: "198.51.100.1/32"}},
-		PolicyIDs:             []string{},
 		Ip:                    "2a06:98c1:54::2419",
 		Subdomain:             "q15l7x2lbw",
 		AnonymizedLogsEnabled: false,
@@ -245,7 +242,6 @@ func TestUpdateTeamsLocation(t *testing.T) {
 		ID:                    id,
 		Name:                  "new",
 		Networks:              []TeamsLocationNetwork{{ID: "8e4c7835436345f0ab395429b187a076", Network: "198.51.100.1/32"}},
-		PolicyIDs:             []string{},
 		Ip:                    "2a06:98c1:54::2419",
 		Subdomain:             "q15l7x2lbw",
 		AnonymizedLogsEnabled: false,