Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1781)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Apr 12, 2024
1 parent b55783b commit 173df7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 40 deletions.
8 changes: 2 additions & 6 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4932,17 +4932,13 @@ 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>
- <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#AccessUser">AccessUser</a>

Methods:

- <code title="get /accounts/{identifier}/access/users">client.ZeroTrust.Access.Users.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#AccessUserService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</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/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#User">User</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{identifier}/access/users">client.ZeroTrust.Access.Users.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#AccessUserService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</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/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/zero_trust#AccessUser">AccessUser</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

#### ActiveSessions

Expand Down
44 changes: 10 additions & 34 deletions zero_trust/accessuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/pagination"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/option"
)
Expand Down Expand Up @@ -39,7 +38,7 @@ func NewAccessUserService(opts ...option.RequestOption) (r *AccessUserService) {
}

// Gets a list of users for an account.
func (r *AccessUserService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[User], err error) {
func (r *AccessUserService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[AccessUser], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -57,11 +56,11 @@ func (r *AccessUserService) List(ctx context.Context, identifier string, opts ..
}

// Gets a list of users for an account.
func (r *AccessUserService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[User] {
func (r *AccessUserService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AccessUser] {
return pagination.NewSinglePageAutoPager(r.List(ctx, identifier, opts...))
}

type User struct {
type AccessUser struct {
// UUID
ID string `json:"id"`
// True if the user has authenticated with Cloudflare Access.
Expand All @@ -80,13 +79,13 @@ type User struct {
// The unique API identifier for the Zero Trust seat.
SeatUID string `json:"seat_uid"`
// The unique API identifier for the user.
UID string `json:"uid"`
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
JSON userJSON `json:"-"`
UID string `json:"uid"`
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
JSON accessUserJSON `json:"-"`
}

// userJSON contains the JSON metadata for the struct [User]
type userJSON struct {
// accessUserJSON contains the JSON metadata for the struct [AccessUser]
type accessUserJSON struct {
ID apijson.Field
AccessSeat apijson.Field
ActiveDeviceCount apijson.Field
Expand All @@ -102,33 +101,10 @@ type userJSON struct {
ExtraFields map[string]apijson.Field
}

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

func (r userJSON) RawJSON() string {
func (r accessUserJSON) RawJSON() string {
return r.raw
}

type UserParam struct {
// True if the user has authenticated with Cloudflare Access.
AccessSeat param.Field[bool] `json:"access_seat"`
// The number of active devices registered to the user.
ActiveDeviceCount param.Field[float64] `json:"active_device_count"`
// The email of the user.
Email param.Field[string] `json:"email" format:"email"`
// True if the user has logged into the WARP client.
GatewaySeat param.Field[bool] `json:"gateway_seat"`
// The time at which the user last successfully logged in.
LastSuccessfulLogin param.Field[time.Time] `json:"last_successful_login" format:"date-time"`
// The name of the user.
Name param.Field[string] `json:"name"`
// The unique API identifier for the Zero Trust seat.
SeatUID param.Field[string] `json:"seat_uid"`
// The unique API identifier for the user.
UID param.Field[string] `json:"uid"`
}

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

0 comments on commit 173df7e

Please sign in to comment.