Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): OpenAPI spec update via Stainless API #1650

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions accounts/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ func (r AccountUpdateResponseEnvelopeSuccess) IsKnown() bool {
type AccountListParams struct {
// Direction to order results.
Direction param.Field[AccountListParamsDirection] `query:"direction"`
// Name of the account.
Name param.Field[string] `query:"name"`
// Page number of paginated results.
Page param.Field[float64] `query:"page"`
// Maximum number of results per page.
Expand Down
1 change: 1 addition & 0 deletions accounts/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestAccountListWithOptionalParams(t *testing.T) {
)
_, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{
Direction: cloudflare.F(accounts.AccountListParamsDirectionDesc),
Name: cloudflare.F("example.com"),
Page: cloudflare.F(1.000000),
PerPage: cloudflare.F(5.000000),
})
Expand Down
9 changes: 7 additions & 2 deletions accounts/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ func (r *MemberService) ListAutoPaging(ctx context.Context, params MemberListPar
}

// Remove a member from an account.
func (r *MemberService) Delete(ctx context.Context, memberID string, body MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) {
func (r *MemberService) Delete(ctx context.Context, memberID string, params MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env MemberDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%v/members/%s", body.AccountID, memberID)
path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -692,6 +692,11 @@ func (r MemberListParamsStatus) IsKnown() bool {

type MemberDeleteParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type MemberDeleteResponseEnvelope struct {
Expand Down
1 change: 1 addition & 0 deletions accounts/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func TestMemberDelete(t *testing.T) {
"4536bcfad5faccb111b47003c79917fa",
accounts.MemberDeleteParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions addressing/addressmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func (r *AddressMapService) ListAutoPaging(ctx context.Context, query AddressMap

// Delete a particular address map owned by the account. An Address Map must be
// disabled before it can be deleted.
func (r *AddressMapService) Delete(ctx context.Context, addressMapID string, body AddressMapDeleteParams, opts ...option.RequestOption) (res *AddressMapDeleteResponse, err error) {
func (r *AddressMapService) Delete(ctx context.Context, addressMapID string, params AddressMapDeleteParams, opts ...option.RequestOption) (res *AddressMapDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", body.AccountID, addressMapID)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", params.AccountID, addressMapID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -554,7 +554,12 @@ type AddressMapListParams struct {

type AddressMapDeleteParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapDeleteResponseEnvelope struct {
Expand Down
1 change: 1 addition & 0 deletions addressing/addressmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func TestAddressMapDelete(t *testing.T) {
"023e105f4ecef8ad9ca31a8372d0c353",
addressing.AddressMapDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
22 changes: 16 additions & 6 deletions addressing/addressmapaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func NewAddressMapAccountService(opts ...option.RequestOption) (r *AddressMapAcc
}

// Add an account as a member of a particular address map.
func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID string, body AddressMapAccountUpdateParams, opts ...option.RequestOption) (res *AddressMapAccountUpdateResponse, err error) {
func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID string, params AddressMapAccountUpdateParams, opts ...option.RequestOption) (res *AddressMapAccountUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapAccountUpdateResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", params.AccountID, addressMapID, params.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...)
if err != nil {
return
Expand All @@ -48,10 +48,10 @@ func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID stri
}

// Remove an account as a member of a particular address map.
func (r *AddressMapAccountService) Delete(ctx context.Context, addressMapID string, body AddressMapAccountDeleteParams, opts ...option.RequestOption) (res *AddressMapAccountDeleteResponse, err error) {
func (r *AddressMapAccountService) Delete(ctx context.Context, addressMapID string, params AddressMapAccountDeleteParams, opts ...option.RequestOption) (res *AddressMapAccountDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapAccountDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", params.AccountID, addressMapID, params.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -112,7 +112,12 @@ func (r AddressMapAccountDeleteResponseArray) ImplementsAddressingAddressMapAcco

type AddressMapAccountUpdateParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapAccountUpdateResponseEnvelope struct {
Expand Down Expand Up @@ -239,7 +244,12 @@ func (r addressMapAccountUpdateResponseEnvelopeResultInfoJSON) RawJSON() string

type AddressMapAccountDeleteParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapAccountDeleteResponseEnvelope struct {
Expand Down
2 changes: 2 additions & 0 deletions addressing/addressmapaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestAddressMapAccountUpdate(t *testing.T) {
"023e105f4ecef8ad9ca31a8372d0c353",
addressing.AddressMapAccountUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down Expand Up @@ -63,6 +64,7 @@ func TestAddressMapAccountDelete(t *testing.T) {
"023e105f4ecef8ad9ca31a8372d0c353",
addressing.AddressMapAccountDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
22 changes: 16 additions & 6 deletions addressing/addressmapip.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func NewAddressMapIPService(opts ...option.RequestOption) (r *AddressMapIPServic
}

// Add an IP from a prefix owned by the account to a particular address map.
func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, ipAddress string, body AddressMapIPUpdateParams, opts ...option.RequestOption) (res *AddressMapIPUpdateResponse, err error) {
func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, ipAddress string, params AddressMapIPUpdateParams, opts ...option.RequestOption) (res *AddressMapIPUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapIPUpdateResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", params.AccountID, addressMapID, ipAddress)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...)
if err != nil {
return
Expand All @@ -48,10 +48,10 @@ func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, i
}

// Remove an IP from a particular address map.
func (r *AddressMapIPService) Delete(ctx context.Context, addressMapID string, ipAddress string, body AddressMapIPDeleteParams, opts ...option.RequestOption) (res *AddressMapIPDeleteResponse, err error) {
func (r *AddressMapIPService) Delete(ctx context.Context, addressMapID string, ipAddress string, params AddressMapIPDeleteParams, opts ...option.RequestOption) (res *AddressMapIPDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapIPDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", params.AccountID, addressMapID, ipAddress)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -112,7 +112,12 @@ func (r AddressMapIPDeleteResponseArray) ImplementsAddressingAddressMapIPDeleteR

type AddressMapIPUpdateParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapIPUpdateResponseEnvelope struct {
Expand Down Expand Up @@ -239,7 +244,12 @@ func (r addressMapIPUpdateResponseEnvelopeResultInfoJSON) RawJSON() string {

type AddressMapIPDeleteParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapIPDeleteResponseEnvelope struct {
Expand Down
2 changes: 2 additions & 0 deletions addressing/addressmapip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestAddressMapIPUpdate(t *testing.T) {
"192.0.2.1",
addressing.AddressMapIPUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down Expand Up @@ -65,6 +66,7 @@ func TestAddressMapIPDelete(t *testing.T) {
"192.0.2.1",
addressing.AddressMapIPDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
40 changes: 16 additions & 24 deletions addressing/addressmapzone.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,10 @@ func NewAddressMapZoneService(opts ...option.RequestOption) (r *AddressMapZoneSe
}

// Add a zone as a member of a particular address map.
func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string, body AddressMapZoneUpdateParams, opts ...option.RequestOption) (res *AddressMapZoneUpdateResponse, err error) {
func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string, params AddressMapZoneUpdateParams, opts ...option.RequestOption) (res *AddressMapZoneUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapZoneUpdateResponseEnvelope
var accountOrZone string
var accountOrZoneID param.Field[string]
if body.AccountID.Present {
accountOrZone = "accounts"
accountOrZoneID = body.AccountID
} else {
accountOrZone = "zones"
accountOrZoneID = body.ZoneID
}
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", params.AccountID, addressMapID, params.ZoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...)
if err != nil {
return
Expand All @@ -57,19 +48,10 @@ func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string,
}

// Remove a zone as a member of a particular address map.
func (r *AddressMapZoneService) Delete(ctx context.Context, addressMapID string, body AddressMapZoneDeleteParams, opts ...option.RequestOption) (res *AddressMapZoneDeleteResponse, err error) {
func (r *AddressMapZoneService) Delete(ctx context.Context, addressMapID string, params AddressMapZoneDeleteParams, opts ...option.RequestOption) (res *AddressMapZoneDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env AddressMapZoneDeleteResponseEnvelope
var accountOrZone string
var accountOrZoneID param.Field[string]
if body.AccountID.Present {
accountOrZone = "accounts"
accountOrZoneID = body.AccountID
} else {
accountOrZone = "zones"
accountOrZoneID = body.ZoneID
}
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID)
path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", params.AccountID, addressMapID, params.ZoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -132,7 +114,12 @@ type AddressMapZoneUpdateParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapZoneUpdateResponseEnvelope struct {
Expand Down Expand Up @@ -261,7 +248,12 @@ type AddressMapZoneDeleteParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type AddressMapZoneDeleteResponseEnvelope struct {
Expand Down
2 changes: 2 additions & 0 deletions addressing/addressmapzone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestAddressMapZoneUpdate(t *testing.T) {
addressing.AddressMapZoneUpdateParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down Expand Up @@ -65,6 +66,7 @@ func TestAddressMapZoneDelete(t *testing.T) {
addressing.AddressMapZoneDeleteParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions addressing/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (r *PrefixService) ListAutoPaging(ctx context.Context, query PrefixListPara
}

// Delete an unapproved prefix owned by the account.
func (r *PrefixService) Delete(ctx context.Context, prefixID string, body PrefixDeleteParams, opts ...option.RequestOption) (res *PrefixDeleteResponse, err error) {
func (r *PrefixService) Delete(ctx context.Context, prefixID string, params PrefixDeleteParams, opts ...option.RequestOption) (res *PrefixDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env PrefixDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", body.AccountID, prefixID)
path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", params.AccountID, prefixID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -310,7 +310,12 @@ type PrefixListParams struct {

type PrefixDeleteParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type PrefixDeleteResponseEnvelope struct {
Expand Down
1 change: 1 addition & 0 deletions addressing/prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func TestPrefixDelete(t *testing.T) {
"023e105f4ecef8ad9ca31a8372d0c353",
addressing.PrefixDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions addressing/prefixdelegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func (r *PrefixDelegationService) ListAutoPaging(ctx context.Context, prefixID s
}

// Delete an account delegation for a given IP prefix.
func (r *PrefixDelegationService) Delete(ctx context.Context, prefixID string, delegationID string, body PrefixDelegationDeleteParams, opts ...option.RequestOption) (res *PrefixDelegationDeleteResponse, err error) {
func (r *PrefixDelegationService) Delete(ctx context.Context, prefixID string, delegationID string, params PrefixDelegationDeleteParams, opts ...option.RequestOption) (res *PrefixDelegationDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env PrefixDelegationDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations/%s", body.AccountID, prefixID, delegationID)
path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations/%s", params.AccountID, prefixID, delegationID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
Expand Down Expand Up @@ -248,7 +248,12 @@ type PrefixDelegationListParams struct {

type PrefixDelegationDeleteParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
AccountID param.Field[string] `path:"account_id,required"`
Body param.Field[interface{}] `json:"body,required"`
}

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

type PrefixDelegationDeleteResponseEnvelope struct {
Expand Down
1 change: 1 addition & 0 deletions addressing/prefixdelegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func TestPrefixDelegationDelete(t *testing.T) {
"d933b1530bc56c9953cf8ce166da8004",
addressing.PrefixDelegationDeleteParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Body: cloudflare.F[any](map[string]interface{}{}),
},
)
if err != nil {
Expand Down
Loading