From 7d3792a90d909cc54465ea9e4eabebb1a7969d44 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 15 Nov 2024 01:34:28 +0000
Subject: [PATCH] feat(api): clean up indirect models (#3608)
---
accounts/token.go | 354 +-------------------------------------
api.md | 19 +--
user/token.go | 425 ++++++++++------------------------------------
3 files changed, 102 insertions(+), 696 deletions(-)
diff --git a/accounts/token.go b/accounts/token.go
index 6afd489bdd3..2ed13d33b35 100644
--- a/accounts/token.go
+++ b/accounts/token.go
@@ -61,7 +61,7 @@ func (r *TokenService) New(ctx context.Context, params TokenNewParams, opts ...o
}
// Update an existing token.
-func (r *TokenService) Update(ctx context.Context, tokenID string, params TokenUpdateParams, opts ...option.RequestOption) (res *TokenUpdateResponse, err error) {
+func (r *TokenService) Update(ctx context.Context, tokenID string, params TokenUpdateParams, opts ...option.RequestOption) (res *user.Token, err error) {
var env TokenUpdateResponseEnvelope
opts = append(r.Options[:], opts...)
if params.AccountID.Value == "" {
@@ -82,7 +82,7 @@ func (r *TokenService) Update(ctx context.Context, tokenID string, params TokenU
}
// List all Account Owned API tokens created for this account.
-func (r *TokenService) List(ctx context.Context, params TokenListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[TokenListResponse], err error) {
+func (r *TokenService) List(ctx context.Context, params TokenListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[user.Token], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
@@ -104,7 +104,7 @@ func (r *TokenService) List(ctx context.Context, params TokenListParams, opts ..
}
// List all Account Owned API tokens created for this account.
-func (r *TokenService) ListAutoPaging(ctx context.Context, params TokenListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[TokenListResponse] {
+func (r *TokenService) ListAutoPaging(ctx context.Context, params TokenListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[user.Token] {
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...))
}
@@ -130,7 +130,7 @@ func (r *TokenService) Delete(ctx context.Context, tokenID string, body TokenDel
}
// Get information about a specific Account Owned API token.
-func (r *TokenService) Get(ctx context.Context, tokenID string, query TokenGetParams, opts ...option.RequestOption) (res *TokenGetResponse, err error) {
+func (r *TokenService) Get(ctx context.Context, tokenID string, query TokenGetParams, opts ...option.RequestOption) (res *user.Token, err error) {
var env TokenGetResponseEnvelope
opts = append(r.Options[:], opts...)
if query.AccountID.Value == "" {
@@ -284,234 +284,6 @@ func (r TokenNewResponseStatus) IsKnown() bool {
return false
}
-type TokenUpdateResponse struct {
- // Token identifier tag.
- ID string `json:"id"`
- Condition TokenUpdateResponseCondition `json:"condition"`
- // The expiration time on or after which the JWT MUST NOT be accepted for
- // processing.
- ExpiresOn time.Time `json:"expires_on" format:"date-time"`
- // The time on which the token was created.
- IssuedOn time.Time `json:"issued_on" format:"date-time"`
- // Last time the token was used.
- LastUsedOn time.Time `json:"last_used_on" format:"date-time"`
- // Last time the token was modified.
- ModifiedOn time.Time `json:"modified_on" format:"date-time"`
- // Token name.
- Name string `json:"name"`
- // The time before which the token MUST NOT be accepted for processing.
- NotBefore time.Time `json:"not_before" format:"date-time"`
- // List of access policies assigned to the token.
- Policies []user.Policy `json:"policies"`
- // Status of the token.
- Status TokenUpdateResponseStatus `json:"status"`
- JSON tokenUpdateResponseJSON `json:"-"`
-}
-
-// tokenUpdateResponseJSON contains the JSON metadata for the struct
-// [TokenUpdateResponse]
-type tokenUpdateResponseJSON struct {
- ID apijson.Field
- Condition apijson.Field
- ExpiresOn apijson.Field
- IssuedOn apijson.Field
- LastUsedOn apijson.Field
- ModifiedOn apijson.Field
- Name apijson.Field
- NotBefore apijson.Field
- Policies apijson.Field
- Status apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUpdateResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenUpdateResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type TokenUpdateResponseCondition struct {
- // Client IP restrictions.
- RequestIP TokenUpdateResponseConditionRequestIP `json:"request.ip"`
- JSON tokenUpdateResponseConditionJSON `json:"-"`
-}
-
-// tokenUpdateResponseConditionJSON contains the JSON metadata for the struct
-// [TokenUpdateResponseCondition]
-type tokenUpdateResponseConditionJSON struct {
- RequestIP apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUpdateResponseCondition) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenUpdateResponseConditionJSON) RawJSON() string {
- return r.raw
-}
-
-// Client IP restrictions.
-type TokenUpdateResponseConditionRequestIP struct {
- // List of IPv4/IPv6 CIDR addresses.
- In []user.CIDRList `json:"in"`
- // List of IPv4/IPv6 CIDR addresses.
- NotIn []user.CIDRList `json:"not_in"`
- JSON tokenUpdateResponseConditionRequestIPJSON `json:"-"`
-}
-
-// tokenUpdateResponseConditionRequestIPJSON contains the JSON metadata for the
-// struct [TokenUpdateResponseConditionRequestIP]
-type tokenUpdateResponseConditionRequestIPJSON struct {
- In apijson.Field
- NotIn apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUpdateResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenUpdateResponseConditionRequestIPJSON) RawJSON() string {
- return r.raw
-}
-
-// Status of the token.
-type TokenUpdateResponseStatus string
-
-const (
- TokenUpdateResponseStatusActive TokenUpdateResponseStatus = "active"
- TokenUpdateResponseStatusDisabled TokenUpdateResponseStatus = "disabled"
- TokenUpdateResponseStatusExpired TokenUpdateResponseStatus = "expired"
-)
-
-func (r TokenUpdateResponseStatus) IsKnown() bool {
- switch r {
- case TokenUpdateResponseStatusActive, TokenUpdateResponseStatusDisabled, TokenUpdateResponseStatusExpired:
- return true
- }
- return false
-}
-
-type TokenListResponse struct {
- // Token identifier tag.
- ID string `json:"id"`
- Condition TokenListResponseCondition `json:"condition"`
- // The expiration time on or after which the JWT MUST NOT be accepted for
- // processing.
- ExpiresOn time.Time `json:"expires_on" format:"date-time"`
- // The time on which the token was created.
- IssuedOn time.Time `json:"issued_on" format:"date-time"`
- // Last time the token was used.
- LastUsedOn time.Time `json:"last_used_on" format:"date-time"`
- // Last time the token was modified.
- ModifiedOn time.Time `json:"modified_on" format:"date-time"`
- // Token name.
- Name string `json:"name"`
- // The time before which the token MUST NOT be accepted for processing.
- NotBefore time.Time `json:"not_before" format:"date-time"`
- // List of access policies assigned to the token.
- Policies []user.Policy `json:"policies"`
- // Status of the token.
- Status TokenListResponseStatus `json:"status"`
- JSON tokenListResponseJSON `json:"-"`
-}
-
-// tokenListResponseJSON contains the JSON metadata for the struct
-// [TokenListResponse]
-type tokenListResponseJSON struct {
- ID apijson.Field
- Condition apijson.Field
- ExpiresOn apijson.Field
- IssuedOn apijson.Field
- LastUsedOn apijson.Field
- ModifiedOn apijson.Field
- Name apijson.Field
- NotBefore apijson.Field
- Policies apijson.Field
- Status apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type TokenListResponseCondition struct {
- // Client IP restrictions.
- RequestIP TokenListResponseConditionRequestIP `json:"request.ip"`
- JSON tokenListResponseConditionJSON `json:"-"`
-}
-
-// tokenListResponseConditionJSON contains the JSON metadata for the struct
-// [TokenListResponseCondition]
-type tokenListResponseConditionJSON struct {
- RequestIP apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenListResponseCondition) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenListResponseConditionJSON) RawJSON() string {
- return r.raw
-}
-
-// Client IP restrictions.
-type TokenListResponseConditionRequestIP struct {
- // List of IPv4/IPv6 CIDR addresses.
- In []user.CIDRList `json:"in"`
- // List of IPv4/IPv6 CIDR addresses.
- NotIn []user.CIDRList `json:"not_in"`
- JSON tokenListResponseConditionRequestIPJSON `json:"-"`
-}
-
-// tokenListResponseConditionRequestIPJSON contains the JSON metadata for the
-// struct [TokenListResponseConditionRequestIP]
-type tokenListResponseConditionRequestIPJSON struct {
- In apijson.Field
- NotIn apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenListResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenListResponseConditionRequestIPJSON) RawJSON() string {
- return r.raw
-}
-
-// Status of the token.
-type TokenListResponseStatus string
-
-const (
- TokenListResponseStatusActive TokenListResponseStatus = "active"
- TokenListResponseStatusDisabled TokenListResponseStatus = "disabled"
- TokenListResponseStatusExpired TokenListResponseStatus = "expired"
-)
-
-func (r TokenListResponseStatus) IsKnown() bool {
- switch r {
- case TokenListResponseStatusActive, TokenListResponseStatusDisabled, TokenListResponseStatusExpired:
- return true
- }
- return false
-}
-
type TokenDeleteResponse struct {
// Identifier
ID string `json:"id,required"`
@@ -534,120 +306,6 @@ func (r tokenDeleteResponseJSON) RawJSON() string {
return r.raw
}
-type TokenGetResponse struct {
- // Token identifier tag.
- ID string `json:"id"`
- Condition TokenGetResponseCondition `json:"condition"`
- // The expiration time on or after which the JWT MUST NOT be accepted for
- // processing.
- ExpiresOn time.Time `json:"expires_on" format:"date-time"`
- // The time on which the token was created.
- IssuedOn time.Time `json:"issued_on" format:"date-time"`
- // Last time the token was used.
- LastUsedOn time.Time `json:"last_used_on" format:"date-time"`
- // Last time the token was modified.
- ModifiedOn time.Time `json:"modified_on" format:"date-time"`
- // Token name.
- Name string `json:"name"`
- // The time before which the token MUST NOT be accepted for processing.
- NotBefore time.Time `json:"not_before" format:"date-time"`
- // List of access policies assigned to the token.
- Policies []user.Policy `json:"policies"`
- // Status of the token.
- Status TokenGetResponseStatus `json:"status"`
- JSON tokenGetResponseJSON `json:"-"`
-}
-
-// tokenGetResponseJSON contains the JSON metadata for the struct
-// [TokenGetResponse]
-type tokenGetResponseJSON struct {
- ID apijson.Field
- Condition apijson.Field
- ExpiresOn apijson.Field
- IssuedOn apijson.Field
- LastUsedOn apijson.Field
- ModifiedOn apijson.Field
- Name apijson.Field
- NotBefore apijson.Field
- Policies apijson.Field
- Status apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenGetResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenGetResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type TokenGetResponseCondition struct {
- // Client IP restrictions.
- RequestIP TokenGetResponseConditionRequestIP `json:"request.ip"`
- JSON tokenGetResponseConditionJSON `json:"-"`
-}
-
-// tokenGetResponseConditionJSON contains the JSON metadata for the struct
-// [TokenGetResponseCondition]
-type tokenGetResponseConditionJSON struct {
- RequestIP apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenGetResponseCondition) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenGetResponseConditionJSON) RawJSON() string {
- return r.raw
-}
-
-// Client IP restrictions.
-type TokenGetResponseConditionRequestIP struct {
- // List of IPv4/IPv6 CIDR addresses.
- In []user.CIDRList `json:"in"`
- // List of IPv4/IPv6 CIDR addresses.
- NotIn []user.CIDRList `json:"not_in"`
- JSON tokenGetResponseConditionRequestIPJSON `json:"-"`
-}
-
-// tokenGetResponseConditionRequestIPJSON contains the JSON metadata for the struct
-// [TokenGetResponseConditionRequestIP]
-type tokenGetResponseConditionRequestIPJSON struct {
- In apijson.Field
- NotIn apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenGetResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenGetResponseConditionRequestIPJSON) RawJSON() string {
- return r.raw
-}
-
-// Status of the token.
-type TokenGetResponseStatus string
-
-const (
- TokenGetResponseStatusActive TokenGetResponseStatus = "active"
- TokenGetResponseStatusDisabled TokenGetResponseStatus = "disabled"
- TokenGetResponseStatusExpired TokenGetResponseStatus = "expired"
-)
-
-func (r TokenGetResponseStatus) IsKnown() bool {
- switch r {
- case TokenGetResponseStatusActive, TokenGetResponseStatusDisabled, TokenGetResponseStatusExpired:
- return true
- }
- return false
-}
-
type TokenVerifyResponse struct {
// Token identifier tag.
ID string `json:"id,required"`
@@ -795,7 +453,7 @@ type TokenUpdateResponseEnvelope struct {
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success TokenUpdateResponseEnvelopeSuccess `json:"success,required"`
- Result TokenUpdateResponse `json:"result"`
+ Result user.Token `json:"result"`
JSON tokenUpdateResponseEnvelopeJSON `json:"-"`
}
@@ -926,7 +584,7 @@ type TokenGetResponseEnvelope struct {
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success TokenGetResponseEnvelopeSuccess `json:"success,required"`
- Result TokenGetResponse `json:"result"`
+ Result user.Token `json:"result"`
JSON tokenGetResponseEnvelopeJSON `json:"-"`
}
diff --git a/api.md b/api.md
index d8f737e629c..d00d33fe10e 100644
--- a/api.md
+++ b/api.md
@@ -84,19 +84,16 @@ Methods:
Response Types:
- accounts.TokenNewResponse
-- accounts.TokenUpdateResponse
-- accounts.TokenListResponse
- accounts.TokenDeleteResponse
-- accounts.TokenGetResponse
- accounts.TokenVerifyResponse
Methods:
- client.Accounts.Tokens.New(ctx context.Context, params accounts.TokenNewParams) (accounts.TokenNewResponse, error)
-- client.Accounts.Tokens.Update(ctx context.Context, tokenID string, params accounts.TokenUpdateParams) (accounts.TokenUpdateResponse, error)
-- client.Accounts.Tokens.List(ctx context.Context, params accounts.TokenListParams) (pagination.V4PagePaginationArray[accounts.TokenListResponse], error)
+- client.Accounts.Tokens.Update(ctx context.Context, tokenID string, params accounts.TokenUpdateParams) (user.Token, error)
+- client.Accounts.Tokens.List(ctx context.Context, params accounts.TokenListParams) (pagination.V4PagePaginationArray[user.Token], error)
- client.Accounts.Tokens.Delete(ctx context.Context, tokenID string, body accounts.TokenDeleteParams) (accounts.TokenDeleteResponse, error)
-- client.Accounts.Tokens.Get(ctx context.Context, tokenID string, query accounts.TokenGetParams) (accounts.TokenGetResponse, error)
+- client.Accounts.Tokens.Get(ctx context.Context, tokenID string, query accounts.TokenGetParams) (user.Token, error)
- client.Accounts.Tokens.Verify(ctx context.Context, query accounts.TokenVerifyParams) (accounts.TokenVerifyResponse, error)
### PermissionGroups
@@ -247,20 +244,18 @@ Response Types:
- user.CIDRList
- user.Policy
+- user.Token
- user.TokenNewResponse
-- user.TokenUpdateResponse
-- user.TokenListResponse
- user.TokenDeleteResponse
-- user.TokenGetResponse
- user.TokenVerifyResponse
Methods:
- client.User.Tokens.New(ctx context.Context, body user.TokenNewParams) (user.TokenNewResponse, error)
-- client.User.Tokens.Update(ctx context.Context, tokenID string, body user.TokenUpdateParams) (user.TokenUpdateResponse, error)
-- client.User.Tokens.List(ctx context.Context, query user.TokenListParams) (pagination.V4PagePaginationArray[user.TokenListResponse], error)
+- client.User.Tokens.Update(ctx context.Context, tokenID string, body user.TokenUpdateParams) (user.Token, error)
+- client.User.Tokens.List(ctx context.Context, query user.TokenListParams) (pagination.V4PagePaginationArray[user.Token], error)
- client.User.Tokens.Delete(ctx context.Context, tokenID string) (user.TokenDeleteResponse, error)
-- client.User.Tokens.Get(ctx context.Context, tokenID string) (user.TokenGetResponse, error)
+- client.User.Tokens.Get(ctx context.Context, tokenID string) (user.Token, error)
- client.User.Tokens.Verify(ctx context.Context) (user.TokenVerifyResponse, error)
### PermissionGroups
diff --git a/user/token.go b/user/token.go
index 4d0ee9e51f5..e7ca5ab0fdb 100644
--- a/user/token.go
+++ b/user/token.go
@@ -56,7 +56,7 @@ func (r *TokenService) New(ctx context.Context, body TokenNewParams, opts ...opt
}
// Update an existing token.
-func (r *TokenService) Update(ctx context.Context, tokenID string, body TokenUpdateParams, opts ...option.RequestOption) (res *TokenUpdateResponse, err error) {
+func (r *TokenService) Update(ctx context.Context, tokenID string, body TokenUpdateParams, opts ...option.RequestOption) (res *Token, err error) {
var env TokenUpdateResponseEnvelope
opts = append(r.Options[:], opts...)
if tokenID == "" {
@@ -73,7 +73,7 @@ func (r *TokenService) Update(ctx context.Context, tokenID string, body TokenUpd
}
// List all access tokens you created.
-func (r *TokenService) List(ctx context.Context, query TokenListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[TokenListResponse], err error) {
+func (r *TokenService) List(ctx context.Context, query TokenListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Token], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
@@ -91,7 +91,7 @@ func (r *TokenService) List(ctx context.Context, query TokenListParams, opts ...
}
// List all access tokens you created.
-func (r *TokenService) ListAutoPaging(ctx context.Context, query TokenListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[TokenListResponse] {
+func (r *TokenService) ListAutoPaging(ctx context.Context, query TokenListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Token] {
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...))
}
@@ -113,7 +113,7 @@ func (r *TokenService) Delete(ctx context.Context, tokenID string, opts ...optio
}
// Get information about a specific token.
-func (r *TokenService) Get(ctx context.Context, tokenID string, opts ...option.RequestOption) (res *TokenGetResponse, err error) {
+func (r *TokenService) Get(ctx context.Context, tokenID string, opts ...option.RequestOption) (res *Token, err error) {
var env TokenGetResponseEnvelope
opts = append(r.Options[:], opts...)
if tokenID == "" {
@@ -313,67 +313,10 @@ func (r PolicyResourcesParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-type TokenParam struct {
- // Token name.
- Name param.Field[string] `json:"name,required"`
- // List of access policies assigned to the token.
- Policies param.Field[[]PolicyParam] `json:"policies,required"`
- // Status of the token.
- Status param.Field[TokenStatus] `json:"status,required"`
- Condition param.Field[TokenConditionParam] `json:"condition"`
- // The expiration time on or after which the JWT MUST NOT be accepted for
- // processing.
- ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"`
- // The time before which the token MUST NOT be accepted for processing.
- NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"`
-}
-
-func (r TokenParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-// Status of the token.
-type TokenStatus string
-
-const (
- TokenStatusActive TokenStatus = "active"
- TokenStatusDisabled TokenStatus = "disabled"
- TokenStatusExpired TokenStatus = "expired"
-)
-
-func (r TokenStatus) IsKnown() bool {
- switch r {
- case TokenStatusActive, TokenStatusDisabled, TokenStatusExpired:
- return true
- }
- return false
-}
-
-type TokenConditionParam struct {
- // Client IP restrictions.
- RequestIP param.Field[TokenConditionRequestIPParam] `json:"request.ip"`
-}
-
-func (r TokenConditionParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-// Client IP restrictions.
-type TokenConditionRequestIPParam struct {
- // List of IPv4/IPv6 CIDR addresses.
- In param.Field[[]CIDRListParam] `json:"in"`
- // List of IPv4/IPv6 CIDR addresses.
- NotIn param.Field[[]CIDRListParam] `json:"not_in"`
-}
-
-func (r TokenConditionRequestIPParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type TokenNewResponse struct {
+type Token struct {
// Token identifier tag.
- ID string `json:"id"`
- Condition TokenNewResponseCondition `json:"condition"`
+ ID string `json:"id"`
+ Condition TokenCondition `json:"condition"`
// The expiration time on or after which the JWT MUST NOT be accepted for
// processing.
ExpiresOn time.Time `json:"expires_on" format:"date-time"`
@@ -390,15 +333,12 @@ type TokenNewResponse struct {
// List of access policies assigned to the token.
Policies []Policy `json:"policies"`
// Status of the token.
- Status TokenNewResponseStatus `json:"status"`
- // The token value.
- Value Value `json:"value"`
- JSON tokenNewResponseJSON `json:"-"`
+ Status TokenStatus `json:"status"`
+ JSON tokenJSON `json:"-"`
}
-// tokenNewResponseJSON contains the JSON metadata for the struct
-// [TokenNewResponse]
-type tokenNewResponseJSON struct {
+// tokenJSON contains the JSON metadata for the struct [Token]
+type tokenJSON struct {
ID apijson.Field
Condition apijson.Field
ExpiresOn apijson.Field
@@ -409,202 +349,126 @@ type tokenNewResponseJSON struct {
NotBefore apijson.Field
Policies apijson.Field
Status apijson.Field
- Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *TokenNewResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *Token) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r tokenNewResponseJSON) RawJSON() string {
+func (r tokenJSON) RawJSON() string {
return r.raw
}
-type TokenNewResponseCondition struct {
+type TokenCondition struct {
// Client IP restrictions.
- RequestIP TokenNewResponseConditionRequestIP `json:"request.ip"`
- JSON tokenNewResponseConditionJSON `json:"-"`
+ RequestIP TokenConditionRequestIP `json:"request.ip"`
+ JSON tokenConditionJSON `json:"-"`
}
-// tokenNewResponseConditionJSON contains the JSON metadata for the struct
-// [TokenNewResponseCondition]
-type tokenNewResponseConditionJSON struct {
+// tokenConditionJSON contains the JSON metadata for the struct [TokenCondition]
+type tokenConditionJSON struct {
RequestIP apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *TokenNewResponseCondition) UnmarshalJSON(data []byte) (err error) {
+func (r *TokenCondition) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r tokenNewResponseConditionJSON) RawJSON() string {
+func (r tokenConditionJSON) RawJSON() string {
return r.raw
}
// Client IP restrictions.
-type TokenNewResponseConditionRequestIP struct {
+type TokenConditionRequestIP struct {
// List of IPv4/IPv6 CIDR addresses.
In []CIDRList `json:"in"`
// List of IPv4/IPv6 CIDR addresses.
- NotIn []CIDRList `json:"not_in"`
- JSON tokenNewResponseConditionRequestIPJSON `json:"-"`
+ NotIn []CIDRList `json:"not_in"`
+ JSON tokenConditionRequestIPJSON `json:"-"`
}
-// tokenNewResponseConditionRequestIPJSON contains the JSON metadata for the struct
-// [TokenNewResponseConditionRequestIP]
-type tokenNewResponseConditionRequestIPJSON struct {
+// tokenConditionRequestIPJSON contains the JSON metadata for the struct
+// [TokenConditionRequestIP]
+type tokenConditionRequestIPJSON struct {
In apijson.Field
NotIn apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *TokenNewResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
+func (r *TokenConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r tokenNewResponseConditionRequestIPJSON) RawJSON() string {
+func (r tokenConditionRequestIPJSON) RawJSON() string {
return r.raw
}
// Status of the token.
-type TokenNewResponseStatus string
+type TokenStatus string
const (
- TokenNewResponseStatusActive TokenNewResponseStatus = "active"
- TokenNewResponseStatusDisabled TokenNewResponseStatus = "disabled"
- TokenNewResponseStatusExpired TokenNewResponseStatus = "expired"
+ TokenStatusActive TokenStatus = "active"
+ TokenStatusDisabled TokenStatus = "disabled"
+ TokenStatusExpired TokenStatus = "expired"
)
-func (r TokenNewResponseStatus) IsKnown() bool {
+func (r TokenStatus) IsKnown() bool {
switch r {
- case TokenNewResponseStatusActive, TokenNewResponseStatusDisabled, TokenNewResponseStatusExpired:
+ case TokenStatusActive, TokenStatusDisabled, TokenStatusExpired:
return true
}
return false
}
-type TokenUpdateResponse struct {
- // Token identifier tag.
- ID string `json:"id"`
- Condition TokenUpdateResponseCondition `json:"condition"`
+type TokenParam struct {
+ Condition param.Field[TokenConditionParam] `json:"condition"`
// The expiration time on or after which the JWT MUST NOT be accepted for
// processing.
- ExpiresOn time.Time `json:"expires_on" format:"date-time"`
- // The time on which the token was created.
- IssuedOn time.Time `json:"issued_on" format:"date-time"`
- // Last time the token was used.
- LastUsedOn time.Time `json:"last_used_on" format:"date-time"`
- // Last time the token was modified.
- ModifiedOn time.Time `json:"modified_on" format:"date-time"`
+ ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"`
// Token name.
- Name string `json:"name"`
+ Name param.Field[string] `json:"name"`
// The time before which the token MUST NOT be accepted for processing.
- NotBefore time.Time `json:"not_before" format:"date-time"`
+ NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"`
// List of access policies assigned to the token.
- Policies []Policy `json:"policies"`
+ Policies param.Field[[]PolicyParam] `json:"policies"`
// Status of the token.
- Status TokenUpdateResponseStatus `json:"status"`
- JSON tokenUpdateResponseJSON `json:"-"`
-}
-
-// tokenUpdateResponseJSON contains the JSON metadata for the struct
-// [TokenUpdateResponse]
-type tokenUpdateResponseJSON struct {
- ID apijson.Field
- Condition apijson.Field
- ExpiresOn apijson.Field
- IssuedOn apijson.Field
- LastUsedOn apijson.Field
- ModifiedOn apijson.Field
- Name apijson.Field
- NotBefore apijson.Field
- Policies apijson.Field
- Status apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUpdateResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
+ Status param.Field[TokenStatus] `json:"status"`
}
-func (r tokenUpdateResponseJSON) RawJSON() string {
- return r.raw
+func (r TokenParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
}
-type TokenUpdateResponseCondition struct {
+type TokenConditionParam struct {
// Client IP restrictions.
- RequestIP TokenUpdateResponseConditionRequestIP `json:"request.ip"`
- JSON tokenUpdateResponseConditionJSON `json:"-"`
-}
-
-// tokenUpdateResponseConditionJSON contains the JSON metadata for the struct
-// [TokenUpdateResponseCondition]
-type tokenUpdateResponseConditionJSON struct {
- RequestIP apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUpdateResponseCondition) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
+ RequestIP param.Field[TokenConditionRequestIPParam] `json:"request.ip"`
}
-func (r tokenUpdateResponseConditionJSON) RawJSON() string {
- return r.raw
+func (r TokenConditionParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
}
// Client IP restrictions.
-type TokenUpdateResponseConditionRequestIP struct {
+type TokenConditionRequestIPParam struct {
// List of IPv4/IPv6 CIDR addresses.
- In []CIDRList `json:"in"`
+ In param.Field[[]CIDRListParam] `json:"in"`
// List of IPv4/IPv6 CIDR addresses.
- NotIn []CIDRList `json:"not_in"`
- JSON tokenUpdateResponseConditionRequestIPJSON `json:"-"`
-}
-
-// tokenUpdateResponseConditionRequestIPJSON contains the JSON metadata for the
-// struct [TokenUpdateResponseConditionRequestIP]
-type tokenUpdateResponseConditionRequestIPJSON struct {
- In apijson.Field
- NotIn apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUpdateResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenUpdateResponseConditionRequestIPJSON) RawJSON() string {
- return r.raw
+ NotIn param.Field[[]CIDRListParam] `json:"not_in"`
}
-// Status of the token.
-type TokenUpdateResponseStatus string
-
-const (
- TokenUpdateResponseStatusActive TokenUpdateResponseStatus = "active"
- TokenUpdateResponseStatusDisabled TokenUpdateResponseStatus = "disabled"
- TokenUpdateResponseStatusExpired TokenUpdateResponseStatus = "expired"
-)
-
-func (r TokenUpdateResponseStatus) IsKnown() bool {
- switch r {
- case TokenUpdateResponseStatusActive, TokenUpdateResponseStatusDisabled, TokenUpdateResponseStatusExpired:
- return true
- }
- return false
+func (r TokenConditionRequestIPParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
}
-type TokenListResponse struct {
+type TokenNewResponse struct {
// Token identifier tag.
- ID string `json:"id"`
- Condition TokenListResponseCondition `json:"condition"`
+ ID string `json:"id"`
+ Condition TokenNewResponseCondition `json:"condition"`
// The expiration time on or after which the JWT MUST NOT be accepted for
// processing.
ExpiresOn time.Time `json:"expires_on" format:"date-time"`
@@ -621,13 +485,15 @@ type TokenListResponse struct {
// List of access policies assigned to the token.
Policies []Policy `json:"policies"`
// Status of the token.
- Status TokenListResponseStatus `json:"status"`
- JSON tokenListResponseJSON `json:"-"`
+ Status TokenNewResponseStatus `json:"status"`
+ // The token value.
+ Value Value `json:"value"`
+ JSON tokenNewResponseJSON `json:"-"`
}
-// tokenListResponseJSON contains the JSON metadata for the struct
-// [TokenListResponse]
-type tokenListResponseJSON struct {
+// tokenNewResponseJSON contains the JSON metadata for the struct
+// [TokenNewResponse]
+type tokenNewResponseJSON struct {
ID apijson.Field
Condition apijson.Field
ExpiresOn apijson.Field
@@ -638,78 +504,79 @@ type tokenListResponseJSON struct {
NotBefore apijson.Field
Policies apijson.Field
Status apijson.Field
+ Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *TokenListResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *TokenNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r tokenListResponseJSON) RawJSON() string {
+func (r tokenNewResponseJSON) RawJSON() string {
return r.raw
}
-type TokenListResponseCondition struct {
+type TokenNewResponseCondition struct {
// Client IP restrictions.
- RequestIP TokenListResponseConditionRequestIP `json:"request.ip"`
- JSON tokenListResponseConditionJSON `json:"-"`
+ RequestIP TokenNewResponseConditionRequestIP `json:"request.ip"`
+ JSON tokenNewResponseConditionJSON `json:"-"`
}
-// tokenListResponseConditionJSON contains the JSON metadata for the struct
-// [TokenListResponseCondition]
-type tokenListResponseConditionJSON struct {
+// tokenNewResponseConditionJSON contains the JSON metadata for the struct
+// [TokenNewResponseCondition]
+type tokenNewResponseConditionJSON struct {
RequestIP apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *TokenListResponseCondition) UnmarshalJSON(data []byte) (err error) {
+func (r *TokenNewResponseCondition) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r tokenListResponseConditionJSON) RawJSON() string {
+func (r tokenNewResponseConditionJSON) RawJSON() string {
return r.raw
}
// Client IP restrictions.
-type TokenListResponseConditionRequestIP struct {
+type TokenNewResponseConditionRequestIP struct {
// List of IPv4/IPv6 CIDR addresses.
In []CIDRList `json:"in"`
// List of IPv4/IPv6 CIDR addresses.
- NotIn []CIDRList `json:"not_in"`
- JSON tokenListResponseConditionRequestIPJSON `json:"-"`
+ NotIn []CIDRList `json:"not_in"`
+ JSON tokenNewResponseConditionRequestIPJSON `json:"-"`
}
-// tokenListResponseConditionRequestIPJSON contains the JSON metadata for the
-// struct [TokenListResponseConditionRequestIP]
-type tokenListResponseConditionRequestIPJSON struct {
+// tokenNewResponseConditionRequestIPJSON contains the JSON metadata for the struct
+// [TokenNewResponseConditionRequestIP]
+type tokenNewResponseConditionRequestIPJSON struct {
In apijson.Field
NotIn apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *TokenListResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
+func (r *TokenNewResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r tokenListResponseConditionRequestIPJSON) RawJSON() string {
+func (r tokenNewResponseConditionRequestIPJSON) RawJSON() string {
return r.raw
}
// Status of the token.
-type TokenListResponseStatus string
+type TokenNewResponseStatus string
const (
- TokenListResponseStatusActive TokenListResponseStatus = "active"
- TokenListResponseStatusDisabled TokenListResponseStatus = "disabled"
- TokenListResponseStatusExpired TokenListResponseStatus = "expired"
+ TokenNewResponseStatusActive TokenNewResponseStatus = "active"
+ TokenNewResponseStatusDisabled TokenNewResponseStatus = "disabled"
+ TokenNewResponseStatusExpired TokenNewResponseStatus = "expired"
)
-func (r TokenListResponseStatus) IsKnown() bool {
+func (r TokenNewResponseStatus) IsKnown() bool {
switch r {
- case TokenListResponseStatusActive, TokenListResponseStatusDisabled, TokenListResponseStatusExpired:
+ case TokenNewResponseStatusActive, TokenNewResponseStatusDisabled, TokenNewResponseStatusExpired:
return true
}
return false
@@ -737,120 +604,6 @@ func (r tokenDeleteResponseJSON) RawJSON() string {
return r.raw
}
-type TokenGetResponse struct {
- // Token identifier tag.
- ID string `json:"id"`
- Condition TokenGetResponseCondition `json:"condition"`
- // The expiration time on or after which the JWT MUST NOT be accepted for
- // processing.
- ExpiresOn time.Time `json:"expires_on" format:"date-time"`
- // The time on which the token was created.
- IssuedOn time.Time `json:"issued_on" format:"date-time"`
- // Last time the token was used.
- LastUsedOn time.Time `json:"last_used_on" format:"date-time"`
- // Last time the token was modified.
- ModifiedOn time.Time `json:"modified_on" format:"date-time"`
- // Token name.
- Name string `json:"name"`
- // The time before which the token MUST NOT be accepted for processing.
- NotBefore time.Time `json:"not_before" format:"date-time"`
- // List of access policies assigned to the token.
- Policies []Policy `json:"policies"`
- // Status of the token.
- Status TokenGetResponseStatus `json:"status"`
- JSON tokenGetResponseJSON `json:"-"`
-}
-
-// tokenGetResponseJSON contains the JSON metadata for the struct
-// [TokenGetResponse]
-type tokenGetResponseJSON struct {
- ID apijson.Field
- Condition apijson.Field
- ExpiresOn apijson.Field
- IssuedOn apijson.Field
- LastUsedOn apijson.Field
- ModifiedOn apijson.Field
- Name apijson.Field
- NotBefore apijson.Field
- Policies apijson.Field
- Status apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenGetResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenGetResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type TokenGetResponseCondition struct {
- // Client IP restrictions.
- RequestIP TokenGetResponseConditionRequestIP `json:"request.ip"`
- JSON tokenGetResponseConditionJSON `json:"-"`
-}
-
-// tokenGetResponseConditionJSON contains the JSON metadata for the struct
-// [TokenGetResponseCondition]
-type tokenGetResponseConditionJSON struct {
- RequestIP apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenGetResponseCondition) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenGetResponseConditionJSON) RawJSON() string {
- return r.raw
-}
-
-// Client IP restrictions.
-type TokenGetResponseConditionRequestIP struct {
- // List of IPv4/IPv6 CIDR addresses.
- In []CIDRList `json:"in"`
- // List of IPv4/IPv6 CIDR addresses.
- NotIn []CIDRList `json:"not_in"`
- JSON tokenGetResponseConditionRequestIPJSON `json:"-"`
-}
-
-// tokenGetResponseConditionRequestIPJSON contains the JSON metadata for the struct
-// [TokenGetResponseConditionRequestIP]
-type tokenGetResponseConditionRequestIPJSON struct {
- In apijson.Field
- NotIn apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenGetResponseConditionRequestIP) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenGetResponseConditionRequestIPJSON) RawJSON() string {
- return r.raw
-}
-
-// Status of the token.
-type TokenGetResponseStatus string
-
-const (
- TokenGetResponseStatusActive TokenGetResponseStatus = "active"
- TokenGetResponseStatusDisabled TokenGetResponseStatus = "disabled"
- TokenGetResponseStatusExpired TokenGetResponseStatus = "expired"
-)
-
-func (r TokenGetResponseStatus) IsKnown() bool {
- switch r {
- case TokenGetResponseStatusActive, TokenGetResponseStatusDisabled, TokenGetResponseStatusExpired:
- return true
- }
- return false
-}
-
type TokenVerifyResponse struct {
// Token identifier tag.
ID string `json:"id,required"`
@@ -994,7 +747,7 @@ type TokenUpdateResponseEnvelope struct {
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success TokenUpdateResponseEnvelopeSuccess `json:"success,required"`
- Result TokenUpdateResponse `json:"result"`
+ Result Token `json:"result"`
JSON tokenUpdateResponseEnvelopeJSON `json:"-"`
}
@@ -1113,7 +866,7 @@ type TokenGetResponseEnvelope struct {
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success TokenGetResponseEnvelopeSuccess `json:"success,required"`
- Result TokenGetResponse `json:"result"`
+ Result Token `json:"result"`
JSON tokenGetResponseEnvelopeJSON `json:"-"`
}