github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/device_code.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package mono_models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"context"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // DeviceCode device code
    18  //
    19  // swagger:model DeviceCode
    20  type DeviceCode struct {
    21  
    22  	// Code used to identify client when client polls for credentials
    23  	// Required: true
    24  	DeviceCode *string `json:"device_code"`
    25  
    26  	// The lifetime in seconds of the "device_code" and "user_code".
    27  	// Required: true
    28  	ExpiresIn *string `json:"expires_in"`
    29  
    30  	// Interval at which to poll for credentials
    31  	Interval int64 `json:"interval,omitempty"`
    32  
    33  	// If true tells client not to use polling.
    34  	Nopoll bool `json:"nopoll,omitempty"`
    35  
    36  	// Code to be enter when user opens verification_uri
    37  	// Required: true
    38  	UserCode *string `json:"user_code"`
    39  
    40  	// The URI that gets opened in the browser by user or cli tool which includes the user_code as a query parameter in the URI.  This page MUST request the user to acknowledge they are authorizing a CLI tool to use their credentials to query the Platform API.  So a BUTTON that says “Authorize”
    41  	// Required: true
    42  	VerificationURIComplete *string `json:"verification_uri_complete"`
    43  }
    44  
    45  // Validate validates this device code
    46  func (m *DeviceCode) Validate(formats strfmt.Registry) error {
    47  	var res []error
    48  
    49  	if err := m.validateDeviceCode(formats); err != nil {
    50  		res = append(res, err)
    51  	}
    52  
    53  	if err := m.validateExpiresIn(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateUserCode(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateVerificationURIComplete(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if len(res) > 0 {
    66  		return errors.CompositeValidationError(res...)
    67  	}
    68  	return nil
    69  }
    70  
    71  func (m *DeviceCode) validateDeviceCode(formats strfmt.Registry) error {
    72  
    73  	if err := validate.Required("device_code", "body", m.DeviceCode); err != nil {
    74  		return err
    75  	}
    76  
    77  	return nil
    78  }
    79  
    80  func (m *DeviceCode) validateExpiresIn(formats strfmt.Registry) error {
    81  
    82  	if err := validate.Required("expires_in", "body", m.ExpiresIn); err != nil {
    83  		return err
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  func (m *DeviceCode) validateUserCode(formats strfmt.Registry) error {
    90  
    91  	if err := validate.Required("user_code", "body", m.UserCode); err != nil {
    92  		return err
    93  	}
    94  
    95  	return nil
    96  }
    97  
    98  func (m *DeviceCode) validateVerificationURIComplete(formats strfmt.Registry) error {
    99  
   100  	if err := validate.Required("verification_uri_complete", "body", m.VerificationURIComplete); err != nil {
   101  		return err
   102  	}
   103  
   104  	return nil
   105  }
   106  
   107  // ContextValidate validates this device code based on context it is used
   108  func (m *DeviceCode) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   109  	return nil
   110  }
   111  
   112  // MarshalBinary interface implementation
   113  func (m *DeviceCode) MarshalBinary() ([]byte, error) {
   114  	if m == nil {
   115  		return nil, nil
   116  	}
   117  	return swag.WriteJSON(m)
   118  }
   119  
   120  // UnmarshalBinary interface implementation
   121  func (m *DeviceCode) UnmarshalBinary(b []byte) error {
   122  	var res DeviceCode
   123  	if err := swag.ReadJSON(b, &res); err != nil {
   124  		return err
   125  	}
   126  	*m = res
   127  	return nil
   128  }