Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1777)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 12, 2024
1 parent 6d825f2 commit 2f1707c
Show file tree
Hide file tree
Showing 86 changed files with 1,101 additions and 95 deletions.
12 changes: 12 additions & 0 deletions accounts/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
96 changes: 6 additions & 90 deletions accounts/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts ..
}

// Modify an account member.
func (r *MemberService) Update(ctx context.Context, memberID string, params MemberUpdateParams, opts ...option.RequestOption) (res *Member, err error) {
func (r *MemberService) Update(ctx context.Context, memberID string, params MemberUpdateParams, opts ...option.RequestOption) (res *shared.User, err error) {
opts = append(r.Options[:], opts...)
var env MemberUpdateResponseEnvelope
path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID)
Expand Down Expand Up @@ -98,7 +98,7 @@ func (r *MemberService) Delete(ctx context.Context, memberID string, params Memb
}

// Get information about a specific member of an account.
func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGetParams, opts ...option.RequestOption) (res *Member, err error) {
func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGetParams, opts ...option.RequestOption) (res *shared.User, err error) {
opts = append(r.Options[:], opts...)
var env MemberGetResponseEnvelope
path := fmt.Sprintf("accounts/%v/members/%s", query.AccountID, memberID)
Expand All @@ -110,90 +110,6 @@ func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGe
return
}

type Member struct {
// Membership identifier tag.
ID string `json:"id,required"`
// Roles assigned to this member.
Roles []MemberRole `json:"roles,required"`
Status interface{} `json:"status,required"`
User MemberUser `json:"user,required"`
JSON memberJSON `json:"-"`
}

// memberJSON contains the JSON metadata for the struct [Member]
type memberJSON struct {
ID apijson.Field
Roles apijson.Field
Status apijson.Field
User apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *Member) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r memberJSON) RawJSON() string {
return r.raw
}

type MemberUser struct {
// The contact email address of the user.
Email string `json:"email,required"`
// Identifier
ID string `json:"id"`
// User's first name
FirstName string `json:"first_name,nullable"`
// User's last name
LastName string `json:"last_name,nullable"`
// Indicates whether two-factor authentication is enabled for the user account.
// Does not apply to API authentication.
TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"`
JSON memberUserJSON `json:"-"`
}

// memberUserJSON contains the JSON metadata for the struct [MemberUser]
type memberUserJSON struct {
Email apijson.Field
ID apijson.Field
FirstName apijson.Field
LastName apijson.Field
TwoFactorAuthenticationEnabled apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *MemberUser) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r memberUserJSON) RawJSON() string {
return r.raw
}

type MemberParam struct {
// Roles assigned to this member.
Roles param.Field[[]MemberRoleParam] `json:"roles,required"`
}

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

type MemberUserParam struct {
// The contact email address of the user.
Email param.Field[string] `json:"email,required"`
// User's first name
FirstName param.Field[string] `json:"first_name"`
// User's last name
LastName param.Field[string] `json:"last_name"`
}

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

type MemberRole struct {
// Role identifier tag.
ID string `json:"id,required"`
Expand Down Expand Up @@ -537,17 +453,17 @@ func (r MemberNewResponseEnvelopeSuccess) IsKnown() bool {

type MemberUpdateParams struct {
AccountID param.Field[interface{}] `path:"account_id,required"`
Member MemberParam `json:"member,required"`
User shared.UserParam `json:"user,required"`
}

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

type MemberUpdateResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Member `json:"result,required"`
Result shared.User `json:"result,required"`
// Whether the API call was successful
Success MemberUpdateResponseEnvelopeSuccess `json:"success,required"`
JSON memberUpdateResponseEnvelopeJSON `json:"-"`
Expand Down Expand Up @@ -719,7 +635,7 @@ type MemberGetParams struct {
type MemberGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Member `json:"result,required"`
Result shared.User `json:"result,required"`
// Whether the API call was successful
Success MemberGetResponseEnvelopeSuccess `json:"success,required"`
JSON memberGetResponseEnvelopeJSON `json:"-"`
Expand Down
3 changes: 2 additions & 1 deletion accounts/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/cloudflare/cloudflare-go/v2"
"github.com/cloudflare/cloudflare-go/v2/accounts"
"github.com/cloudflare/cloudflare-go/v2/internal/shared"
"github.com/cloudflare/cloudflare-go/v2/internal/testutil"
"github.com/cloudflare/cloudflare-go/v2/option"
)
Expand Down Expand Up @@ -62,7 +63,7 @@ func TestMemberUpdate(t *testing.T) {
"4536bcfad5faccb111b47003c79917fa",
accounts.MemberUpdateParams{
AccountID: cloudflare.F[any](map[string]interface{}{}),
Member: accounts.MemberParam{
User: shared.UserParam{
Roles: cloudflare.F([]accounts.MemberRoleParam{{
ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"),
}, {
Expand Down
12 changes: 12 additions & 0 deletions acm/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions addressing/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions alerting/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
15 changes: 11 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Shared Params Types

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#UserParam">UserParam</a>

# Shared Response Types

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#AuditLog">AuditLog</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CloudflareTunnel">CloudflareTunnel</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#ErrorData">ErrorData</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#ResponseInfo">ResponseInfo</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#User">User</a>

# Accounts

Expand All @@ -28,12 +33,10 @@ Methods:

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberParam">MemberParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberRoleParam">MemberRoleParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#Member">Member</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberRole">MemberRole</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberWithInviteCode">MemberWithInviteCode</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberListResponse">MemberListResponse</a>
Expand All @@ -42,10 +45,10 @@ Response Types:
Methods:

- <code title="post /accounts/{account_id}/members">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberNewParams">MemberNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberWithInviteCode">MemberWithInviteCode</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /accounts/{account_id}/members/{member_id}">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, memberID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberUpdateParams">MemberUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#Member">Member</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /accounts/{account_id}/members/{member_id}">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, memberID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberUpdateParams">MemberUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#User">User</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/members">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberListParams">MemberListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberListResponse">MemberListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /accounts/{account_id}/members/{member_id}">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, memberID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberDeleteParams">MemberDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberDeleteResponse">MemberDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/members/{member_id}">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, memberID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberGetParams">MemberGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#Member">Member</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/members/{member_id}">client.Accounts.Members.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, memberID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts">accounts</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#MemberGetParams">MemberGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#User">User</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Roles

Expand Down Expand Up @@ -4937,6 +4940,10 @@ Methods:

### Users

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#UserParam">UserParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#User">User</a>
Expand Down
12 changes: 12 additions & 0 deletions argo/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions audit_logs/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions billing/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions bot_management/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions brand_protection/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
12 changes: 12 additions & 0 deletions cache/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ type ErrorData = shared.ErrorData

// This is an alias to an internal type.
type ResponseInfo = shared.ResponseInfo

// This is an alias to an internal type.
type User = shared.User

// This is an alias to an internal type.
type UserUser = shared.UserUser

// This is an alias to an internal type.
type UserParam = shared.UserParam

// This is an alias to an internal type.
type UserUserParam = shared.UserUserParam
Loading

0 comments on commit 2f1707c

Please sign in to comment.