github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/enroll_request.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package modelscapi
     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  // EnrollRequest enroll request
    18  //
    19  // enroll request model
    20  //
    21  // swagger:model EnrollRequest
    22  type EnrollRequest struct {
    23  
    24  	// attachment_key is generated in your crowdsec backoffice account and allows you to enroll your machines to your BO account
    25  	// Required: true
    26  	// Pattern: ^[a-zA-Z0-9]+$
    27  	AttachmentKey *string `json:"attachment_key"`
    28  
    29  	// The name that will be display in the console for the instance
    30  	Name string `json:"name,omitempty"`
    31  
    32  	// To force enroll the instance
    33  	Overwrite bool `json:"overwrite,omitempty"`
    34  
    35  	// Tags to apply on the console for the instance
    36  	Tags []string `json:"tags"`
    37  }
    38  
    39  // Validate validates this enroll request
    40  func (m *EnrollRequest) Validate(formats strfmt.Registry) error {
    41  	var res []error
    42  
    43  	if err := m.validateAttachmentKey(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if len(res) > 0 {
    48  		return errors.CompositeValidationError(res...)
    49  	}
    50  	return nil
    51  }
    52  
    53  func (m *EnrollRequest) validateAttachmentKey(formats strfmt.Registry) error {
    54  
    55  	if err := validate.Required("attachment_key", "body", m.AttachmentKey); err != nil {
    56  		return err
    57  	}
    58  
    59  	if err := validate.Pattern("attachment_key", "body", *m.AttachmentKey, `^[a-zA-Z0-9]+$`); err != nil {
    60  		return err
    61  	}
    62  
    63  	return nil
    64  }
    65  
    66  // ContextValidate validates this enroll request based on context it is used
    67  func (m *EnrollRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    68  	return nil
    69  }
    70  
    71  // MarshalBinary interface implementation
    72  func (m *EnrollRequest) MarshalBinary() ([]byte, error) {
    73  	if m == nil {
    74  		return nil, nil
    75  	}
    76  	return swag.WriteJSON(m)
    77  }
    78  
    79  // UnmarshalBinary interface implementation
    80  func (m *EnrollRequest) UnmarshalBinary(b []byte) error {
    81  	var res EnrollRequest
    82  	if err := swag.ReadJSON(b, &res); err != nil {
    83  		return err
    84  	}
    85  	*m = res
    86  	return nil
    87  }