Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1707)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Apr 9, 2024
1 parent 9f92541 commit 114c2fa
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 18 deletions.
36 changes: 33 additions & 3 deletions accounts/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/internal/shared"
"github.com/cloudflare/cloudflare-go/v2/option"
"github.com/cloudflare/cloudflare-go/v2/user"
)

// MemberService contains methods and other services that help with interacting
Expand Down Expand Up @@ -243,8 +244,6 @@ func (r memberUserJSON) RawJSON() string {
return r.raw
}

type MemberRoles []string

type MemberWithInviteCode struct {
// Membership identifier tag.
ID string `json:"id,required"`
Expand Down Expand Up @@ -393,7 +392,7 @@ type MemberListResponse struct {
// Member Name.
Name string `json:"name,required,nullable"`
// Roles assigned to this Member.
Roles []Role `json:"roles,required"`
Roles []MemberListResponseRole `json:"roles,required"`
// A member's status in the organization.
Status MemberListResponseStatus `json:"status,required"`
JSON memberListResponseJSON `json:"-"`
Expand All @@ -419,6 +418,37 @@ func (r memberListResponseJSON) RawJSON() string {
return r.raw
}

type MemberListResponseRole struct {
// Role identifier tag.
ID string `json:"id,required"`
// Description of role's permissions.
Description string `json:"description,required"`
// Role Name.
Name string `json:"name,required"`
// Access permissions for this User.
Permissions []user.Permission `json:"permissions,required"`
JSON memberListResponseRoleJSON `json:"-"`
}

// memberListResponseRoleJSON contains the JSON metadata for the struct
// [MemberListResponseRole]
type memberListResponseRoleJSON struct {
ID apijson.Field
Description apijson.Field
Name apijson.Field
Permissions apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// A member's status in the organization.
type MemberListResponseStatus string

Expand Down
19 changes: 10 additions & 9 deletions accounts/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewRoleService(opts ...option.RequestOption) (r *RoleService) {
}

// Get all available roles for an account.
func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Role], err error) {
func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[RoleListResponse], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -52,7 +52,7 @@ func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...op
}

// Get all available roles for an account.
func (r *RoleService) ListAutoPaging(ctx context.Context, query RoleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Role] {
func (r *RoleService) ListAutoPaging(ctx context.Context, query RoleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[RoleListResponse] {
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
}

Expand Down Expand Up @@ -100,20 +100,21 @@ func (r PermissionGrantParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type Role struct {
type RoleListResponse struct {
// Role identifier tag.
ID string `json:"id,required"`
// Description of role's permissions.
Description string `json:"description,required"`
// Role Name.
Name string `json:"name,required"`
// Access permissions for this User.
Permissions []user.Permission `json:"permissions,required"`
JSON roleJSON `json:"-"`
Permissions []user.Permission `json:"permissions,required"`
JSON roleListResponseJSON `json:"-"`
}

// roleJSON contains the JSON metadata for the struct [Role]
type roleJSON struct {
// roleListResponseJSON contains the JSON metadata for the struct
// [RoleListResponse]
type roleListResponseJSON struct {
ID apijson.Field
Description apijson.Field
Name apijson.Field
Expand All @@ -122,11 +123,11 @@ type roleJSON struct {
ExtraFields map[string]apijson.Field
}

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

func (r roleJSON) RawJSON() string {
func (r roleListResponseJSON) RawJSON() string {
return r.raw
}

Expand Down
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Methods:
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#MemberRoles">MemberRoles</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>
- <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>
Expand All @@ -51,11 +51,11 @@ Params Types:
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#PermissionGrant">PermissionGrant</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#Role">Role</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#RoleListResponse">RoleListResponse</a>

Methods:

- <code title="get /accounts/{account_id}/roles">client.Accounts.Roles.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#RoleService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</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#RoleListParams">RoleListParams</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#SinglePage">SinglePage</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#Role">Role</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/roles">client.Accounts.Roles.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#RoleService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</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#RoleListParams">RoleListParams</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#SinglePage">SinglePage</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#RoleListResponse">RoleListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/roles/{role_id}">client.Accounts.Roles.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/accounts#RoleService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, roleID interface{}, 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#RoleGetParams">RoleGetParams</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#UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion">UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# OriginCACertificates
Expand Down
2 changes: 1 addition & 1 deletion memberships/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type Membership struct {
// All access permissions for the user at the account.
Permissions MembershipPermissions `json:"permissions"`
// List of role names for the user at the account.
Roles accounts.MemberRoles `json:"roles"`
Roles accounts.MemberRole `json:"roles"`
// Status of this membership.
Status MembershipStatus `json:"status"`
JSON membershipJSON `json:"-"`
Expand Down
33 changes: 31 additions & 2 deletions user/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"time"

"github.com/cloudflare/cloudflare-go/v2/accounts"
"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/pagination"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
Expand Down Expand Up @@ -101,7 +100,7 @@ type Invite struct {
// Organization name.
OrganizationName string `json:"organization_name"`
// Roles to be assigned to this user.
Roles []accounts.Role `json:"roles"`
Roles []InviteRole `json:"roles"`
// Current status of the invitation.
Status InviteStatus `json:"status"`
JSON inviteJSON `json:"-"`
Expand Down Expand Up @@ -131,6 +130,36 @@ func (r inviteJSON) RawJSON() string {
return r.raw
}

type InviteRole struct {
// Role identifier tag.
ID string `json:"id,required"`
// Description of role's permissions.
Description string `json:"description,required"`
// Role Name.
Name string `json:"name,required"`
// Access permissions for this User.
Permissions []Permission `json:"permissions,required"`
JSON inviteRoleJSON `json:"-"`
}

// inviteRoleJSON contains the JSON metadata for the struct [InviteRole]
type inviteRoleJSON struct {
ID apijson.Field
Description apijson.Field
Name apijson.Field
Permissions apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// Current status of the invitation.
type InviteStatus string

Expand Down

0 comments on commit 114c2fa

Please sign in to comment.