github.com/digitalocean/go-netbox@v0.0.2/netbox/models/r_i_r.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright 2020 The go-netbox Authors.
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //   http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  //
    17  
    18  package models
    19  
    20  // This file was generated by the swagger tool.
    21  // Editing this file might prove futile when you re-run the swagger generate command
    22  
    23  import (
    24  	"context"
    25  
    26  	"github.com/go-openapi/errors"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/swag"
    29  	"github.com/go-openapi/validate"
    30  )
    31  
    32  // RIR r i r
    33  //
    34  // swagger:model RIR
    35  type RIR struct {
    36  
    37  	// Aggregate count
    38  	// Read Only: true
    39  	AggregateCount int64 `json:"aggregate_count,omitempty"`
    40  
    41  	// Created
    42  	// Read Only: true
    43  	// Format: date
    44  	Created strfmt.Date `json:"created,omitempty"`
    45  
    46  	// Custom fields
    47  	CustomFields interface{} `json:"custom_fields,omitempty"`
    48  
    49  	// Description
    50  	// Max Length: 200
    51  	Description string `json:"description,omitempty"`
    52  
    53  	// Display
    54  	// Read Only: true
    55  	Display string `json:"display,omitempty"`
    56  
    57  	// Id
    58  	// Read Only: true
    59  	ID int64 `json:"id,omitempty"`
    60  
    61  	// Private
    62  	//
    63  	// IP space managed by this RIR is considered private
    64  	IsPrivate bool `json:"is_private,omitempty"`
    65  
    66  	// Last updated
    67  	// Read Only: true
    68  	// Format: date-time
    69  	LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
    70  
    71  	// Name
    72  	// Required: true
    73  	// Max Length: 100
    74  	// Min Length: 1
    75  	Name *string `json:"name"`
    76  
    77  	// Slug
    78  	// Required: true
    79  	// Max Length: 100
    80  	// Min Length: 1
    81  	// Pattern: ^[-a-zA-Z0-9_]+$
    82  	Slug *string `json:"slug"`
    83  
    84  	// Url
    85  	// Read Only: true
    86  	// Format: uri
    87  	URL strfmt.URI `json:"url,omitempty"`
    88  }
    89  
    90  // Validate validates this r i r
    91  func (m *RIR) Validate(formats strfmt.Registry) error {
    92  	var res []error
    93  
    94  	if err := m.validateCreated(formats); err != nil {
    95  		res = append(res, err)
    96  	}
    97  
    98  	if err := m.validateDescription(formats); err != nil {
    99  		res = append(res, err)
   100  	}
   101  
   102  	if err := m.validateLastUpdated(formats); err != nil {
   103  		res = append(res, err)
   104  	}
   105  
   106  	if err := m.validateName(formats); err != nil {
   107  		res = append(res, err)
   108  	}
   109  
   110  	if err := m.validateSlug(formats); err != nil {
   111  		res = append(res, err)
   112  	}
   113  
   114  	if err := m.validateURL(formats); err != nil {
   115  		res = append(res, err)
   116  	}
   117  
   118  	if len(res) > 0 {
   119  		return errors.CompositeValidationError(res...)
   120  	}
   121  	return nil
   122  }
   123  
   124  func (m *RIR) validateCreated(formats strfmt.Registry) error {
   125  	if swag.IsZero(m.Created) { // not required
   126  		return nil
   127  	}
   128  
   129  	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
   130  		return err
   131  	}
   132  
   133  	return nil
   134  }
   135  
   136  func (m *RIR) validateDescription(formats strfmt.Registry) error {
   137  	if swag.IsZero(m.Description) { // not required
   138  		return nil
   139  	}
   140  
   141  	if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
   142  		return err
   143  	}
   144  
   145  	return nil
   146  }
   147  
   148  func (m *RIR) validateLastUpdated(formats strfmt.Registry) error {
   149  	if swag.IsZero(m.LastUpdated) { // not required
   150  		return nil
   151  	}
   152  
   153  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   154  		return err
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  func (m *RIR) validateName(formats strfmt.Registry) error {
   161  
   162  	if err := validate.Required("name", "body", m.Name); err != nil {
   163  		return err
   164  	}
   165  
   166  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   167  		return err
   168  	}
   169  
   170  	if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil {
   171  		return err
   172  	}
   173  
   174  	return nil
   175  }
   176  
   177  func (m *RIR) validateSlug(formats strfmt.Registry) error {
   178  
   179  	if err := validate.Required("slug", "body", m.Slug); err != nil {
   180  		return err
   181  	}
   182  
   183  	if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil {
   184  		return err
   185  	}
   186  
   187  	if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil {
   188  		return err
   189  	}
   190  
   191  	if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil {
   192  		return err
   193  	}
   194  
   195  	return nil
   196  }
   197  
   198  func (m *RIR) validateURL(formats strfmt.Registry) error {
   199  	if swag.IsZero(m.URL) { // not required
   200  		return nil
   201  	}
   202  
   203  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   204  		return err
   205  	}
   206  
   207  	return nil
   208  }
   209  
   210  // ContextValidate validate this r i r based on the context it is used
   211  func (m *RIR) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   212  	var res []error
   213  
   214  	if err := m.contextValidateAggregateCount(ctx, formats); err != nil {
   215  		res = append(res, err)
   216  	}
   217  
   218  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   219  		res = append(res, err)
   220  	}
   221  
   222  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   223  		res = append(res, err)
   224  	}
   225  
   226  	if err := m.contextValidateID(ctx, formats); err != nil {
   227  		res = append(res, err)
   228  	}
   229  
   230  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   231  		res = append(res, err)
   232  	}
   233  
   234  	if err := m.contextValidateURL(ctx, formats); err != nil {
   235  		res = append(res, err)
   236  	}
   237  
   238  	if len(res) > 0 {
   239  		return errors.CompositeValidationError(res...)
   240  	}
   241  	return nil
   242  }
   243  
   244  func (m *RIR) contextValidateAggregateCount(ctx context.Context, formats strfmt.Registry) error {
   245  
   246  	if err := validate.ReadOnly(ctx, "aggregate_count", "body", int64(m.AggregateCount)); err != nil {
   247  		return err
   248  	}
   249  
   250  	return nil
   251  }
   252  
   253  func (m *RIR) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   254  
   255  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   256  		return err
   257  	}
   258  
   259  	return nil
   260  }
   261  
   262  func (m *RIR) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   263  
   264  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   265  		return err
   266  	}
   267  
   268  	return nil
   269  }
   270  
   271  func (m *RIR) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   272  
   273  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   274  		return err
   275  	}
   276  
   277  	return nil
   278  }
   279  
   280  func (m *RIR) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   281  
   282  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   283  		return err
   284  	}
   285  
   286  	return nil
   287  }
   288  
   289  func (m *RIR) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   290  
   291  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   292  		return err
   293  	}
   294  
   295  	return nil
   296  }
   297  
   298  // MarshalBinary interface implementation
   299  func (m *RIR) MarshalBinary() ([]byte, error) {
   300  	if m == nil {
   301  		return nil, nil
   302  	}
   303  	return swag.WriteJSON(m)
   304  }
   305  
   306  // UnmarshalBinary interface implementation
   307  func (m *RIR) UnmarshalBinary(b []byte) error {
   308  	var res RIR
   309  	if err := swag.ReadJSON(b, &res); err != nil {
   310  		return err
   311  	}
   312  	*m = res
   313  	return nil
   314  }