github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_tenant_group.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  // WritableTenantGroup writable tenant group
    33  //
    34  // swagger:model WritableTenantGroup
    35  type WritableTenantGroup struct {
    36  
    37  	// depth
    38  	// Read Only: true
    39  	Depth int64 `json:"_depth,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  	// Last updated
    62  	// Read Only: true
    63  	// Format: date-time
    64  	LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
    65  
    66  	// Name
    67  	// Required: true
    68  	// Max Length: 100
    69  	// Min Length: 1
    70  	Name *string `json:"name"`
    71  
    72  	// Parent
    73  	Parent *int64 `json:"parent,omitempty"`
    74  
    75  	// Slug
    76  	// Required: true
    77  	// Max Length: 100
    78  	// Min Length: 1
    79  	// Pattern: ^[-a-zA-Z0-9_]+$
    80  	Slug *string `json:"slug"`
    81  
    82  	// Tenant count
    83  	// Read Only: true
    84  	TenantCount int64 `json:"tenant_count,omitempty"`
    85  
    86  	// Url
    87  	// Read Only: true
    88  	// Format: uri
    89  	URL strfmt.URI `json:"url,omitempty"`
    90  }
    91  
    92  // Validate validates this writable tenant group
    93  func (m *WritableTenantGroup) Validate(formats strfmt.Registry) error {
    94  	var res []error
    95  
    96  	if err := m.validateCreated(formats); err != nil {
    97  		res = append(res, err)
    98  	}
    99  
   100  	if err := m.validateDescription(formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	if err := m.validateLastUpdated(formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	if err := m.validateName(formats); err != nil {
   109  		res = append(res, err)
   110  	}
   111  
   112  	if err := m.validateSlug(formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.validateURL(formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if len(res) > 0 {
   121  		return errors.CompositeValidationError(res...)
   122  	}
   123  	return nil
   124  }
   125  
   126  func (m *WritableTenantGroup) validateCreated(formats strfmt.Registry) error {
   127  	if swag.IsZero(m.Created) { // not required
   128  		return nil
   129  	}
   130  
   131  	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
   132  		return err
   133  	}
   134  
   135  	return nil
   136  }
   137  
   138  func (m *WritableTenantGroup) validateDescription(formats strfmt.Registry) error {
   139  	if swag.IsZero(m.Description) { // not required
   140  		return nil
   141  	}
   142  
   143  	if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
   144  		return err
   145  	}
   146  
   147  	return nil
   148  }
   149  
   150  func (m *WritableTenantGroup) validateLastUpdated(formats strfmt.Registry) error {
   151  	if swag.IsZero(m.LastUpdated) { // not required
   152  		return nil
   153  	}
   154  
   155  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   156  		return err
   157  	}
   158  
   159  	return nil
   160  }
   161  
   162  func (m *WritableTenantGroup) validateName(formats strfmt.Registry) error {
   163  
   164  	if err := validate.Required("name", "body", m.Name); err != nil {
   165  		return err
   166  	}
   167  
   168  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   169  		return err
   170  	}
   171  
   172  	if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil {
   173  		return err
   174  	}
   175  
   176  	return nil
   177  }
   178  
   179  func (m *WritableTenantGroup) validateSlug(formats strfmt.Registry) error {
   180  
   181  	if err := validate.Required("slug", "body", m.Slug); err != nil {
   182  		return err
   183  	}
   184  
   185  	if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil {
   186  		return err
   187  	}
   188  
   189  	if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil {
   190  		return err
   191  	}
   192  
   193  	if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil {
   194  		return err
   195  	}
   196  
   197  	return nil
   198  }
   199  
   200  func (m *WritableTenantGroup) validateURL(formats strfmt.Registry) error {
   201  	if swag.IsZero(m.URL) { // not required
   202  		return nil
   203  	}
   204  
   205  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   206  		return err
   207  	}
   208  
   209  	return nil
   210  }
   211  
   212  // ContextValidate validate this writable tenant group based on the context it is used
   213  func (m *WritableTenantGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   214  	var res []error
   215  
   216  	if err := m.contextValidateDepth(ctx, formats); err != nil {
   217  		res = append(res, err)
   218  	}
   219  
   220  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   221  		res = append(res, err)
   222  	}
   223  
   224  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   225  		res = append(res, err)
   226  	}
   227  
   228  	if err := m.contextValidateID(ctx, formats); err != nil {
   229  		res = append(res, err)
   230  	}
   231  
   232  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   233  		res = append(res, err)
   234  	}
   235  
   236  	if err := m.contextValidateTenantCount(ctx, formats); err != nil {
   237  		res = append(res, err)
   238  	}
   239  
   240  	if err := m.contextValidateURL(ctx, formats); err != nil {
   241  		res = append(res, err)
   242  	}
   243  
   244  	if len(res) > 0 {
   245  		return errors.CompositeValidationError(res...)
   246  	}
   247  	return nil
   248  }
   249  
   250  func (m *WritableTenantGroup) contextValidateDepth(ctx context.Context, formats strfmt.Registry) error {
   251  
   252  	if err := validate.ReadOnly(ctx, "_depth", "body", int64(m.Depth)); err != nil {
   253  		return err
   254  	}
   255  
   256  	return nil
   257  }
   258  
   259  func (m *WritableTenantGroup) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   260  
   261  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   262  		return err
   263  	}
   264  
   265  	return nil
   266  }
   267  
   268  func (m *WritableTenantGroup) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   269  
   270  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   271  		return err
   272  	}
   273  
   274  	return nil
   275  }
   276  
   277  func (m *WritableTenantGroup) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   278  
   279  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   280  		return err
   281  	}
   282  
   283  	return nil
   284  }
   285  
   286  func (m *WritableTenantGroup) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   287  
   288  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   289  		return err
   290  	}
   291  
   292  	return nil
   293  }
   294  
   295  func (m *WritableTenantGroup) contextValidateTenantCount(ctx context.Context, formats strfmt.Registry) error {
   296  
   297  	if err := validate.ReadOnly(ctx, "tenant_count", "body", int64(m.TenantCount)); err != nil {
   298  		return err
   299  	}
   300  
   301  	return nil
   302  }
   303  
   304  func (m *WritableTenantGroup) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   305  
   306  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   307  		return err
   308  	}
   309  
   310  	return nil
   311  }
   312  
   313  // MarshalBinary interface implementation
   314  func (m *WritableTenantGroup) MarshalBinary() ([]byte, error) {
   315  	if m == nil {
   316  		return nil, nil
   317  	}
   318  	return swag.WriteJSON(m)
   319  }
   320  
   321  // UnmarshalBinary interface implementation
   322  func (m *WritableTenantGroup) UnmarshalBinary(b []byte) error {
   323  	var res WritableTenantGroup
   324  	if err := swag.ReadJSON(b, &res); err != nil {
   325  		return err
   326  	}
   327  	*m = res
   328  	return nil
   329  }