Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1837)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 23, 2024
1 parent 9299404 commit 50cc379
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 65 deletions.
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3580,12 +3580,14 @@ Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#ACLParam">ACLParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#ACLConfigurationParam">ACLConfigurationParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#AllowedProtocol">AllowedProtocol</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#SubnetUnionParam">SubnetUnionParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#ACL">ACL</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#ACLConfiguration">ACLConfiguration</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#AllowedProtocol">AllowedProtocol</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit">magic_transit</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/magic_transit#SubnetUnion">SubnetUnion</a>

Methods:
Expand Down
90 changes: 27 additions & 63 deletions magic_transit/siteacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ type ACL struct {
LAN1 ACLConfiguration `json:"lan_1"`
LAN2 ACLConfiguration `json:"lan_2"`
// The name of the ACL.
Name string `json:"name"`
Protocols []ACLProtocol `json:"protocols"`
JSON aclJSON `json:"-"`
Name string `json:"name"`
Protocols []AllowedProtocol `json:"protocols"`
JSON aclJSON `json:"-"`
}

// aclJSON contains the JSON metadata for the struct [ACL]
Expand All @@ -149,24 +149,6 @@ func (r aclJSON) RawJSON() string {
return r.raw
}

// Array of allowed communication protocols between configured LANs. If no
// protocols are provided, all protocols are allowed.
type ACLProtocol string

const (
ACLProtocolTCP ACLProtocol = "tcp"
ACLProtocolUdp ACLProtocol = "udp"
ACLProtocolIcmp ACLProtocol = "icmp"
)

func (r ACLProtocol) IsKnown() bool {
switch r {
case ACLProtocolTCP, ACLProtocolUdp, ACLProtocolIcmp:
return true
}
return false
}

// Bidirectional ACL policy for network traffic within a site.
type ACLParam struct {
// Description for the ACL.
Expand All @@ -179,8 +161,8 @@ type ACLParam struct {
LAN1 param.Field[ACLConfigurationParam] `json:"lan_1"`
LAN2 param.Field[ACLConfigurationParam] `json:"lan_2"`
// The name of the ACL.
Name param.Field[string] `json:"name"`
Protocols param.Field[[]ACLProtocol] `json:"protocols"`
Name param.Field[string] `json:"name"`
Protocols param.Field[[]AllowedProtocol] `json:"protocols"`
}

func (r ACLParam) MarshalJSON() (data []byte, err error) {
Expand Down Expand Up @@ -237,6 +219,24 @@ func (r ACLConfigurationParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Array of allowed communication protocols between configured LANs. If no
// protocols are provided, all protocols are allowed.
type AllowedProtocol string

const (
AllowedProtocolTCP AllowedProtocol = "tcp"
AllowedProtocolUdp AllowedProtocol = "udp"
AllowedProtocolIcmp AllowedProtocol = "icmp"
)

func (r AllowedProtocol) IsKnown() bool {
switch r {
case AllowedProtocolTCP, AllowedProtocolUdp, AllowedProtocolIcmp:
return true
}
return false
}

// A valid IPv4 address.
//
// Union satisfied by [shared.UnionString] or [shared.UnionString].
Expand Down Expand Up @@ -279,32 +279,14 @@ type SiteACLNewParams struct {
// will forward traffic to Cloudflare. If set to "true", the policy will forward
// traffic locally on the Magic WAN Connector. If not included in request, will
// default to false.
ForwardLocally param.Field[bool] `json:"forward_locally"`
Protocols param.Field[[]SiteACLNewParamsProtocol] `json:"protocols"`
ForwardLocally param.Field[bool] `json:"forward_locally"`
Protocols param.Field[[]AllowedProtocol] `json:"protocols"`
}

func (r SiteACLNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Array of allowed communication protocols between configured LANs. If no
// protocols are provided, all protocols are allowed.
type SiteACLNewParamsProtocol string

const (
SiteACLNewParamsProtocolTCP SiteACLNewParamsProtocol = "tcp"
SiteACLNewParamsProtocolUdp SiteACLNewParamsProtocol = "udp"
SiteACLNewParamsProtocolIcmp SiteACLNewParamsProtocol = "icmp"
)

func (r SiteACLNewParamsProtocol) IsKnown() bool {
switch r {
case SiteACLNewParamsProtocolTCP, SiteACLNewParamsProtocolUdp, SiteACLNewParamsProtocolIcmp:
return true
}
return false
}

type SiteACLNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Expand Down Expand Up @@ -362,32 +344,14 @@ type SiteACLUpdateParams struct {
LAN1 param.Field[ACLConfigurationParam] `json:"lan_1"`
LAN2 param.Field[ACLConfigurationParam] `json:"lan_2"`
// The name of the ACL.
Name param.Field[string] `json:"name"`
Protocols param.Field[[]SiteACLUpdateParamsProtocol] `json:"protocols"`
Name param.Field[string] `json:"name"`
Protocols param.Field[[]AllowedProtocol] `json:"protocols"`
}

func (r SiteACLUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Array of allowed communication protocols between configured LANs. If no
// protocols are provided, all protocols are allowed.
type SiteACLUpdateParamsProtocol string

const (
SiteACLUpdateParamsProtocolTCP SiteACLUpdateParamsProtocol = "tcp"
SiteACLUpdateParamsProtocolUdp SiteACLUpdateParamsProtocol = "udp"
SiteACLUpdateParamsProtocolIcmp SiteACLUpdateParamsProtocol = "icmp"
)

func (r SiteACLUpdateParamsProtocol) IsKnown() bool {
switch r {
case SiteACLUpdateParamsProtocolTCP, SiteACLUpdateParamsProtocolUdp, SiteACLUpdateParamsProtocolIcmp:
return true
}
return false
}

type SiteACLUpdateResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Expand Down
4 changes: 2 additions & 2 deletions magic_transit/siteacl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestSiteACLNewWithOptionalParams(t *testing.T) {
Name: cloudflare.F("PIN Pad - Cash Register"),
Description: cloudflare.F("Allows local traffic between PIN pads and cash register."),
ForwardLocally: cloudflare.F(true),
Protocols: cloudflare.F([]magic_transit.SiteACLNewParamsProtocol{magic_transit.SiteACLNewParamsProtocolTCP, magic_transit.SiteACLNewParamsProtocolUdp, magic_transit.SiteACLNewParamsProtocolIcmp}),
Protocols: cloudflare.F([]magic_transit.AllowedProtocol{magic_transit.AllowedProtocolTCP, magic_transit.AllowedProtocolUdp, magic_transit.AllowedProtocolIcmp}),
},
)
if err != nil {
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestSiteACLUpdateWithOptionalParams(t *testing.T) {
Subnets: cloudflare.F([]magic_transit.SubnetUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}),
}),
Name: cloudflare.F("PIN Pad - Cash Register"),
Protocols: cloudflare.F([]magic_transit.SiteACLUpdateParamsProtocol{magic_transit.SiteACLUpdateParamsProtocolTCP, magic_transit.SiteACLUpdateParamsProtocolUdp, magic_transit.SiteACLUpdateParamsProtocolIcmp}),
Protocols: cloudflare.F([]magic_transit.AllowedProtocol{magic_transit.AllowedProtocolTCP, magic_transit.AllowedProtocolUdp, magic_transit.AllowedProtocolIcmp}),
},
)
if err != nil {
Expand Down

0 comments on commit 50cc379

Please sign in to comment.