Files
autogits/common/gitea-generated/models/access_token.go

110 lines
2.5 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// AccessToken AccessToken represents an API access token.
//
// swagger:model AccessToken
type AccessToken struct {
// The timestamp when the token was created
// Format: date-time
Created strfmt.DateTime `json:"created_at,omitempty"`
// The unique identifier of the access token
ID int64 `json:"id,omitempty"`
// The name of the access token
Name string `json:"name,omitempty"`
// The scopes granted to this access token
Scopes []string `json:"scopes"`
// The SHA1 hash of the access token
Token string `json:"sha1,omitempty"`
// The last eight characters of the token
TokenLastEight string `json:"token_last_eight,omitempty"`
// The timestamp when the token was last used
// Format: date-time
Updated strfmt.DateTime `json:"last_used_at,omitempty"`
}
// Validate validates this access token
func (m *AccessToken) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreated(formats); err != nil {
res = append(res, err)
}
if err := m.validateUpdated(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *AccessToken) validateCreated(formats strfmt.Registry) error {
if swag.IsZero(m.Created) { // not required
return nil
}
if err := validate.FormatOf("created_at", "body", "date-time", m.Created.String(), formats); err != nil {
return err
}
return nil
}
func (m *AccessToken) validateUpdated(formats strfmt.Registry) error {
if swag.IsZero(m.Updated) { // not required
return nil
}
if err := validate.FormatOf("last_used_at", "body", "date-time", m.Updated.String(), formats); err != nil {
return err
}
return nil
}
// ContextValidate validates this access token based on context it is used
func (m *AccessToken) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *AccessToken) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *AccessToken) UnmarshalBinary(b []byte) error {
var res AccessToken
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}