github.com/digitalocean/go-netbox@v0.0.2/netbox/models/prefix.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  	"encoding/json"
    26  	"strconv"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/strfmt"
    30  	"github.com/go-openapi/swag"
    31  	"github.com/go-openapi/validate"
    32  )
    33  
    34  // Prefix prefix
    35  //
    36  // swagger:model Prefix
    37  type Prefix struct {
    38  
    39  	// depth
    40  	// Read Only: true
    41  	Depth int64 `json:"_depth,omitempty"`
    42  
    43  	// Children
    44  	// Read Only: true
    45  	Children int64 `json:"children,omitempty"`
    46  
    47  	// Created
    48  	// Read Only: true
    49  	// Format: date
    50  	Created strfmt.Date `json:"created,omitempty"`
    51  
    52  	// Custom fields
    53  	CustomFields interface{} `json:"custom_fields,omitempty"`
    54  
    55  	// Description
    56  	// Max Length: 200
    57  	Description string `json:"description,omitempty"`
    58  
    59  	// Display
    60  	// Read Only: true
    61  	Display string `json:"display,omitempty"`
    62  
    63  	// family
    64  	Family *PrefixFamily `json:"family,omitempty"`
    65  
    66  	// Id
    67  	// Read Only: true
    68  	ID int64 `json:"id,omitempty"`
    69  
    70  	// Is a pool
    71  	//
    72  	// All IP addresses within this prefix are considered usable
    73  	IsPool bool `json:"is_pool,omitempty"`
    74  
    75  	// Last updated
    76  	// Read Only: true
    77  	// Format: date-time
    78  	LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
    79  
    80  	// Prefix
    81  	//
    82  	// IPv4 or IPv6 network with mask
    83  	// Required: true
    84  	Prefix *string `json:"prefix"`
    85  
    86  	// role
    87  	Role *NestedRole `json:"role,omitempty"`
    88  
    89  	// site
    90  	Site *NestedSite `json:"site,omitempty"`
    91  
    92  	// status
    93  	Status *PrefixStatus `json:"status,omitempty"`
    94  
    95  	// tags
    96  	Tags []*NestedTag `json:"tags"`
    97  
    98  	// tenant
    99  	Tenant *NestedTenant `json:"tenant,omitempty"`
   100  
   101  	// Url
   102  	// Read Only: true
   103  	// Format: uri
   104  	URL strfmt.URI `json:"url,omitempty"`
   105  
   106  	// vlan
   107  	Vlan *NestedVLAN `json:"vlan,omitempty"`
   108  
   109  	// vrf
   110  	Vrf *NestedVRF `json:"vrf,omitempty"`
   111  }
   112  
   113  // Validate validates this prefix
   114  func (m *Prefix) Validate(formats strfmt.Registry) error {
   115  	var res []error
   116  
   117  	if err := m.validateCreated(formats); err != nil {
   118  		res = append(res, err)
   119  	}
   120  
   121  	if err := m.validateDescription(formats); err != nil {
   122  		res = append(res, err)
   123  	}
   124  
   125  	if err := m.validateFamily(formats); err != nil {
   126  		res = append(res, err)
   127  	}
   128  
   129  	if err := m.validateLastUpdated(formats); err != nil {
   130  		res = append(res, err)
   131  	}
   132  
   133  	if err := m.validatePrefix(formats); err != nil {
   134  		res = append(res, err)
   135  	}
   136  
   137  	if err := m.validateRole(formats); err != nil {
   138  		res = append(res, err)
   139  	}
   140  
   141  	if err := m.validateSite(formats); err != nil {
   142  		res = append(res, err)
   143  	}
   144  
   145  	if err := m.validateStatus(formats); err != nil {
   146  		res = append(res, err)
   147  	}
   148  
   149  	if err := m.validateTags(formats); err != nil {
   150  		res = append(res, err)
   151  	}
   152  
   153  	if err := m.validateTenant(formats); err != nil {
   154  		res = append(res, err)
   155  	}
   156  
   157  	if err := m.validateURL(formats); err != nil {
   158  		res = append(res, err)
   159  	}
   160  
   161  	if err := m.validateVlan(formats); err != nil {
   162  		res = append(res, err)
   163  	}
   164  
   165  	if err := m.validateVrf(formats); err != nil {
   166  		res = append(res, err)
   167  	}
   168  
   169  	if len(res) > 0 {
   170  		return errors.CompositeValidationError(res...)
   171  	}
   172  	return nil
   173  }
   174  
   175  func (m *Prefix) validateCreated(formats strfmt.Registry) error {
   176  	if swag.IsZero(m.Created) { // not required
   177  		return nil
   178  	}
   179  
   180  	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
   181  		return err
   182  	}
   183  
   184  	return nil
   185  }
   186  
   187  func (m *Prefix) validateDescription(formats strfmt.Registry) error {
   188  	if swag.IsZero(m.Description) { // not required
   189  		return nil
   190  	}
   191  
   192  	if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
   193  		return err
   194  	}
   195  
   196  	return nil
   197  }
   198  
   199  func (m *Prefix) validateFamily(formats strfmt.Registry) error {
   200  	if swag.IsZero(m.Family) { // not required
   201  		return nil
   202  	}
   203  
   204  	if m.Family != nil {
   205  		if err := m.Family.Validate(formats); err != nil {
   206  			if ve, ok := err.(*errors.Validation); ok {
   207  				return ve.ValidateName("family")
   208  			} else if ce, ok := err.(*errors.CompositeError); ok {
   209  				return ce.ValidateName("family")
   210  			}
   211  			return err
   212  		}
   213  	}
   214  
   215  	return nil
   216  }
   217  
   218  func (m *Prefix) validateLastUpdated(formats strfmt.Registry) error {
   219  	if swag.IsZero(m.LastUpdated) { // not required
   220  		return nil
   221  	}
   222  
   223  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   224  		return err
   225  	}
   226  
   227  	return nil
   228  }
   229  
   230  func (m *Prefix) validatePrefix(formats strfmt.Registry) error {
   231  
   232  	if err := validate.Required("prefix", "body", m.Prefix); err != nil {
   233  		return err
   234  	}
   235  
   236  	return nil
   237  }
   238  
   239  func (m *Prefix) validateRole(formats strfmt.Registry) error {
   240  	if swag.IsZero(m.Role) { // not required
   241  		return nil
   242  	}
   243  
   244  	if m.Role != nil {
   245  		if err := m.Role.Validate(formats); err != nil {
   246  			if ve, ok := err.(*errors.Validation); ok {
   247  				return ve.ValidateName("role")
   248  			} else if ce, ok := err.(*errors.CompositeError); ok {
   249  				return ce.ValidateName("role")
   250  			}
   251  			return err
   252  		}
   253  	}
   254  
   255  	return nil
   256  }
   257  
   258  func (m *Prefix) validateSite(formats strfmt.Registry) error {
   259  	if swag.IsZero(m.Site) { // not required
   260  		return nil
   261  	}
   262  
   263  	if m.Site != nil {
   264  		if err := m.Site.Validate(formats); err != nil {
   265  			if ve, ok := err.(*errors.Validation); ok {
   266  				return ve.ValidateName("site")
   267  			} else if ce, ok := err.(*errors.CompositeError); ok {
   268  				return ce.ValidateName("site")
   269  			}
   270  			return err
   271  		}
   272  	}
   273  
   274  	return nil
   275  }
   276  
   277  func (m *Prefix) validateStatus(formats strfmt.Registry) error {
   278  	if swag.IsZero(m.Status) { // not required
   279  		return nil
   280  	}
   281  
   282  	if m.Status != nil {
   283  		if err := m.Status.Validate(formats); err != nil {
   284  			if ve, ok := err.(*errors.Validation); ok {
   285  				return ve.ValidateName("status")
   286  			} else if ce, ok := err.(*errors.CompositeError); ok {
   287  				return ce.ValidateName("status")
   288  			}
   289  			return err
   290  		}
   291  	}
   292  
   293  	return nil
   294  }
   295  
   296  func (m *Prefix) validateTags(formats strfmt.Registry) error {
   297  	if swag.IsZero(m.Tags) { // not required
   298  		return nil
   299  	}
   300  
   301  	for i := 0; i < len(m.Tags); i++ {
   302  		if swag.IsZero(m.Tags[i]) { // not required
   303  			continue
   304  		}
   305  
   306  		if m.Tags[i] != nil {
   307  			if err := m.Tags[i].Validate(formats); err != nil {
   308  				if ve, ok := err.(*errors.Validation); ok {
   309  					return ve.ValidateName("tags" + "." + strconv.Itoa(i))
   310  				} else if ce, ok := err.(*errors.CompositeError); ok {
   311  					return ce.ValidateName("tags" + "." + strconv.Itoa(i))
   312  				}
   313  				return err
   314  			}
   315  		}
   316  
   317  	}
   318  
   319  	return nil
   320  }
   321  
   322  func (m *Prefix) validateTenant(formats strfmt.Registry) error {
   323  	if swag.IsZero(m.Tenant) { // not required
   324  		return nil
   325  	}
   326  
   327  	if m.Tenant != nil {
   328  		if err := m.Tenant.Validate(formats); err != nil {
   329  			if ve, ok := err.(*errors.Validation); ok {
   330  				return ve.ValidateName("tenant")
   331  			} else if ce, ok := err.(*errors.CompositeError); ok {
   332  				return ce.ValidateName("tenant")
   333  			}
   334  			return err
   335  		}
   336  	}
   337  
   338  	return nil
   339  }
   340  
   341  func (m *Prefix) validateURL(formats strfmt.Registry) error {
   342  	if swag.IsZero(m.URL) { // not required
   343  		return nil
   344  	}
   345  
   346  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   347  		return err
   348  	}
   349  
   350  	return nil
   351  }
   352  
   353  func (m *Prefix) validateVlan(formats strfmt.Registry) error {
   354  	if swag.IsZero(m.Vlan) { // not required
   355  		return nil
   356  	}
   357  
   358  	if m.Vlan != nil {
   359  		if err := m.Vlan.Validate(formats); err != nil {
   360  			if ve, ok := err.(*errors.Validation); ok {
   361  				return ve.ValidateName("vlan")
   362  			} else if ce, ok := err.(*errors.CompositeError); ok {
   363  				return ce.ValidateName("vlan")
   364  			}
   365  			return err
   366  		}
   367  	}
   368  
   369  	return nil
   370  }
   371  
   372  func (m *Prefix) validateVrf(formats strfmt.Registry) error {
   373  	if swag.IsZero(m.Vrf) { // not required
   374  		return nil
   375  	}
   376  
   377  	if m.Vrf != nil {
   378  		if err := m.Vrf.Validate(formats); err != nil {
   379  			if ve, ok := err.(*errors.Validation); ok {
   380  				return ve.ValidateName("vrf")
   381  			} else if ce, ok := err.(*errors.CompositeError); ok {
   382  				return ce.ValidateName("vrf")
   383  			}
   384  			return err
   385  		}
   386  	}
   387  
   388  	return nil
   389  }
   390  
   391  // ContextValidate validate this prefix based on the context it is used
   392  func (m *Prefix) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   393  	var res []error
   394  
   395  	if err := m.contextValidateDepth(ctx, formats); err != nil {
   396  		res = append(res, err)
   397  	}
   398  
   399  	if err := m.contextValidateChildren(ctx, formats); err != nil {
   400  		res = append(res, err)
   401  	}
   402  
   403  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   404  		res = append(res, err)
   405  	}
   406  
   407  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   408  		res = append(res, err)
   409  	}
   410  
   411  	if err := m.contextValidateFamily(ctx, formats); err != nil {
   412  		res = append(res, err)
   413  	}
   414  
   415  	if err := m.contextValidateID(ctx, formats); err != nil {
   416  		res = append(res, err)
   417  	}
   418  
   419  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   420  		res = append(res, err)
   421  	}
   422  
   423  	if err := m.contextValidateRole(ctx, formats); err != nil {
   424  		res = append(res, err)
   425  	}
   426  
   427  	if err := m.contextValidateSite(ctx, formats); err != nil {
   428  		res = append(res, err)
   429  	}
   430  
   431  	if err := m.contextValidateStatus(ctx, formats); err != nil {
   432  		res = append(res, err)
   433  	}
   434  
   435  	if err := m.contextValidateTags(ctx, formats); err != nil {
   436  		res = append(res, err)
   437  	}
   438  
   439  	if err := m.contextValidateTenant(ctx, formats); err != nil {
   440  		res = append(res, err)
   441  	}
   442  
   443  	if err := m.contextValidateURL(ctx, formats); err != nil {
   444  		res = append(res, err)
   445  	}
   446  
   447  	if err := m.contextValidateVlan(ctx, formats); err != nil {
   448  		res = append(res, err)
   449  	}
   450  
   451  	if err := m.contextValidateVrf(ctx, formats); err != nil {
   452  		res = append(res, err)
   453  	}
   454  
   455  	if len(res) > 0 {
   456  		return errors.CompositeValidationError(res...)
   457  	}
   458  	return nil
   459  }
   460  
   461  func (m *Prefix) contextValidateDepth(ctx context.Context, formats strfmt.Registry) error {
   462  
   463  	if err := validate.ReadOnly(ctx, "_depth", "body", int64(m.Depth)); err != nil {
   464  		return err
   465  	}
   466  
   467  	return nil
   468  }
   469  
   470  func (m *Prefix) contextValidateChildren(ctx context.Context, formats strfmt.Registry) error {
   471  
   472  	if err := validate.ReadOnly(ctx, "children", "body", int64(m.Children)); err != nil {
   473  		return err
   474  	}
   475  
   476  	return nil
   477  }
   478  
   479  func (m *Prefix) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   480  
   481  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   482  		return err
   483  	}
   484  
   485  	return nil
   486  }
   487  
   488  func (m *Prefix) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   489  
   490  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   491  		return err
   492  	}
   493  
   494  	return nil
   495  }
   496  
   497  func (m *Prefix) contextValidateFamily(ctx context.Context, formats strfmt.Registry) error {
   498  
   499  	if m.Family != nil {
   500  		if err := m.Family.ContextValidate(ctx, formats); err != nil {
   501  			if ve, ok := err.(*errors.Validation); ok {
   502  				return ve.ValidateName("family")
   503  			} else if ce, ok := err.(*errors.CompositeError); ok {
   504  				return ce.ValidateName("family")
   505  			}
   506  			return err
   507  		}
   508  	}
   509  
   510  	return nil
   511  }
   512  
   513  func (m *Prefix) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   514  
   515  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   516  		return err
   517  	}
   518  
   519  	return nil
   520  }
   521  
   522  func (m *Prefix) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   523  
   524  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   525  		return err
   526  	}
   527  
   528  	return nil
   529  }
   530  
   531  func (m *Prefix) contextValidateRole(ctx context.Context, formats strfmt.Registry) error {
   532  
   533  	if m.Role != nil {
   534  		if err := m.Role.ContextValidate(ctx, formats); err != nil {
   535  			if ve, ok := err.(*errors.Validation); ok {
   536  				return ve.ValidateName("role")
   537  			} else if ce, ok := err.(*errors.CompositeError); ok {
   538  				return ce.ValidateName("role")
   539  			}
   540  			return err
   541  		}
   542  	}
   543  
   544  	return nil
   545  }
   546  
   547  func (m *Prefix) contextValidateSite(ctx context.Context, formats strfmt.Registry) error {
   548  
   549  	if m.Site != nil {
   550  		if err := m.Site.ContextValidate(ctx, formats); err != nil {
   551  			if ve, ok := err.(*errors.Validation); ok {
   552  				return ve.ValidateName("site")
   553  			} else if ce, ok := err.(*errors.CompositeError); ok {
   554  				return ce.ValidateName("site")
   555  			}
   556  			return err
   557  		}
   558  	}
   559  
   560  	return nil
   561  }
   562  
   563  func (m *Prefix) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {
   564  
   565  	if m.Status != nil {
   566  		if err := m.Status.ContextValidate(ctx, formats); err != nil {
   567  			if ve, ok := err.(*errors.Validation); ok {
   568  				return ve.ValidateName("status")
   569  			} else if ce, ok := err.(*errors.CompositeError); ok {
   570  				return ce.ValidateName("status")
   571  			}
   572  			return err
   573  		}
   574  	}
   575  
   576  	return nil
   577  }
   578  
   579  func (m *Prefix) contextValidateTags(ctx context.Context, formats strfmt.Registry) error {
   580  
   581  	for i := 0; i < len(m.Tags); i++ {
   582  
   583  		if m.Tags[i] != nil {
   584  			if err := m.Tags[i].ContextValidate(ctx, formats); err != nil {
   585  				if ve, ok := err.(*errors.Validation); ok {
   586  					return ve.ValidateName("tags" + "." + strconv.Itoa(i))
   587  				} else if ce, ok := err.(*errors.CompositeError); ok {
   588  					return ce.ValidateName("tags" + "." + strconv.Itoa(i))
   589  				}
   590  				return err
   591  			}
   592  		}
   593  
   594  	}
   595  
   596  	return nil
   597  }
   598  
   599  func (m *Prefix) contextValidateTenant(ctx context.Context, formats strfmt.Registry) error {
   600  
   601  	if m.Tenant != nil {
   602  		if err := m.Tenant.ContextValidate(ctx, formats); err != nil {
   603  			if ve, ok := err.(*errors.Validation); ok {
   604  				return ve.ValidateName("tenant")
   605  			} else if ce, ok := err.(*errors.CompositeError); ok {
   606  				return ce.ValidateName("tenant")
   607  			}
   608  			return err
   609  		}
   610  	}
   611  
   612  	return nil
   613  }
   614  
   615  func (m *Prefix) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   616  
   617  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   618  		return err
   619  	}
   620  
   621  	return nil
   622  }
   623  
   624  func (m *Prefix) contextValidateVlan(ctx context.Context, formats strfmt.Registry) error {
   625  
   626  	if m.Vlan != nil {
   627  		if err := m.Vlan.ContextValidate(ctx, formats); err != nil {
   628  			if ve, ok := err.(*errors.Validation); ok {
   629  				return ve.ValidateName("vlan")
   630  			} else if ce, ok := err.(*errors.CompositeError); ok {
   631  				return ce.ValidateName("vlan")
   632  			}
   633  			return err
   634  		}
   635  	}
   636  
   637  	return nil
   638  }
   639  
   640  func (m *Prefix) contextValidateVrf(ctx context.Context, formats strfmt.Registry) error {
   641  
   642  	if m.Vrf != nil {
   643  		if err := m.Vrf.ContextValidate(ctx, formats); err != nil {
   644  			if ve, ok := err.(*errors.Validation); ok {
   645  				return ve.ValidateName("vrf")
   646  			} else if ce, ok := err.(*errors.CompositeError); ok {
   647  				return ce.ValidateName("vrf")
   648  			}
   649  			return err
   650  		}
   651  	}
   652  
   653  	return nil
   654  }
   655  
   656  // MarshalBinary interface implementation
   657  func (m *Prefix) MarshalBinary() ([]byte, error) {
   658  	if m == nil {
   659  		return nil, nil
   660  	}
   661  	return swag.WriteJSON(m)
   662  }
   663  
   664  // UnmarshalBinary interface implementation
   665  func (m *Prefix) UnmarshalBinary(b []byte) error {
   666  	var res Prefix
   667  	if err := swag.ReadJSON(b, &res); err != nil {
   668  		return err
   669  	}
   670  	*m = res
   671  	return nil
   672  }
   673  
   674  // PrefixFamily Family
   675  //
   676  // swagger:model PrefixFamily
   677  type PrefixFamily struct {
   678  
   679  	// label
   680  	// Required: true
   681  	// Enum: [IPv4 IPv6]
   682  	Label *string `json:"label"`
   683  
   684  	// value
   685  	// Required: true
   686  	// Enum: [4 6]
   687  	Value *int64 `json:"value"`
   688  }
   689  
   690  // Validate validates this prefix family
   691  func (m *PrefixFamily) Validate(formats strfmt.Registry) error {
   692  	var res []error
   693  
   694  	if err := m.validateLabel(formats); err != nil {
   695  		res = append(res, err)
   696  	}
   697  
   698  	if err := m.validateValue(formats); err != nil {
   699  		res = append(res, err)
   700  	}
   701  
   702  	if len(res) > 0 {
   703  		return errors.CompositeValidationError(res...)
   704  	}
   705  	return nil
   706  }
   707  
   708  var prefixFamilyTypeLabelPropEnum []interface{}
   709  
   710  func init() {
   711  	var res []string
   712  	if err := json.Unmarshal([]byte(`["IPv4","IPv6"]`), &res); err != nil {
   713  		panic(err)
   714  	}
   715  	for _, v := range res {
   716  		prefixFamilyTypeLabelPropEnum = append(prefixFamilyTypeLabelPropEnum, v)
   717  	}
   718  }
   719  
   720  const (
   721  
   722  	// PrefixFamilyLabelIPV4 captures enum value "IPv4"
   723  	PrefixFamilyLabelIPV4 string = "IPv4"
   724  
   725  	// PrefixFamilyLabelIPV6 captures enum value "IPv6"
   726  	PrefixFamilyLabelIPV6 string = "IPv6"
   727  )
   728  
   729  // prop value enum
   730  func (m *PrefixFamily) validateLabelEnum(path, location string, value string) error {
   731  	if err := validate.EnumCase(path, location, value, prefixFamilyTypeLabelPropEnum, true); err != nil {
   732  		return err
   733  	}
   734  	return nil
   735  }
   736  
   737  func (m *PrefixFamily) validateLabel(formats strfmt.Registry) error {
   738  
   739  	if err := validate.Required("family"+"."+"label", "body", m.Label); err != nil {
   740  		return err
   741  	}
   742  
   743  	// value enum
   744  	if err := m.validateLabelEnum("family"+"."+"label", "body", *m.Label); err != nil {
   745  		return err
   746  	}
   747  
   748  	return nil
   749  }
   750  
   751  var prefixFamilyTypeValuePropEnum []interface{}
   752  
   753  func init() {
   754  	var res []int64
   755  	if err := json.Unmarshal([]byte(`[4,6]`), &res); err != nil {
   756  		panic(err)
   757  	}
   758  	for _, v := range res {
   759  		prefixFamilyTypeValuePropEnum = append(prefixFamilyTypeValuePropEnum, v)
   760  	}
   761  }
   762  
   763  // prop value enum
   764  func (m *PrefixFamily) validateValueEnum(path, location string, value int64) error {
   765  	if err := validate.EnumCase(path, location, value, prefixFamilyTypeValuePropEnum, true); err != nil {
   766  		return err
   767  	}
   768  	return nil
   769  }
   770  
   771  func (m *PrefixFamily) validateValue(formats strfmt.Registry) error {
   772  
   773  	if err := validate.Required("family"+"."+"value", "body", m.Value); err != nil {
   774  		return err
   775  	}
   776  
   777  	// value enum
   778  	if err := m.validateValueEnum("family"+"."+"value", "body", *m.Value); err != nil {
   779  		return err
   780  	}
   781  
   782  	return nil
   783  }
   784  
   785  // ContextValidate validate this prefix family based on the context it is used
   786  func (m *PrefixFamily) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   787  	var res []error
   788  
   789  	if len(res) > 0 {
   790  		return errors.CompositeValidationError(res...)
   791  	}
   792  	return nil
   793  }
   794  
   795  // MarshalBinary interface implementation
   796  func (m *PrefixFamily) MarshalBinary() ([]byte, error) {
   797  	if m == nil {
   798  		return nil, nil
   799  	}
   800  	return swag.WriteJSON(m)
   801  }
   802  
   803  // UnmarshalBinary interface implementation
   804  func (m *PrefixFamily) UnmarshalBinary(b []byte) error {
   805  	var res PrefixFamily
   806  	if err := swag.ReadJSON(b, &res); err != nil {
   807  		return err
   808  	}
   809  	*m = res
   810  	return nil
   811  }
   812  
   813  // PrefixStatus Status
   814  //
   815  // swagger:model PrefixStatus
   816  type PrefixStatus struct {
   817  
   818  	// label
   819  	// Required: true
   820  	// Enum: [Container Active Reserved Deprecated]
   821  	Label *string `json:"label"`
   822  
   823  	// value
   824  	// Required: true
   825  	// Enum: [container active reserved deprecated]
   826  	Value *string `json:"value"`
   827  }
   828  
   829  // Validate validates this prefix status
   830  func (m *PrefixStatus) Validate(formats strfmt.Registry) error {
   831  	var res []error
   832  
   833  	if err := m.validateLabel(formats); err != nil {
   834  		res = append(res, err)
   835  	}
   836  
   837  	if err := m.validateValue(formats); err != nil {
   838  		res = append(res, err)
   839  	}
   840  
   841  	if len(res) > 0 {
   842  		return errors.CompositeValidationError(res...)
   843  	}
   844  	return nil
   845  }
   846  
   847  var prefixStatusTypeLabelPropEnum []interface{}
   848  
   849  func init() {
   850  	var res []string
   851  	if err := json.Unmarshal([]byte(`["Container","Active","Reserved","Deprecated"]`), &res); err != nil {
   852  		panic(err)
   853  	}
   854  	for _, v := range res {
   855  		prefixStatusTypeLabelPropEnum = append(prefixStatusTypeLabelPropEnum, v)
   856  	}
   857  }
   858  
   859  const (
   860  
   861  	// PrefixStatusLabelContainer captures enum value "Container"
   862  	PrefixStatusLabelContainer string = "Container"
   863  
   864  	// PrefixStatusLabelActive captures enum value "Active"
   865  	PrefixStatusLabelActive string = "Active"
   866  
   867  	// PrefixStatusLabelReserved captures enum value "Reserved"
   868  	PrefixStatusLabelReserved string = "Reserved"
   869  
   870  	// PrefixStatusLabelDeprecated captures enum value "Deprecated"
   871  	PrefixStatusLabelDeprecated string = "Deprecated"
   872  )
   873  
   874  // prop value enum
   875  func (m *PrefixStatus) validateLabelEnum(path, location string, value string) error {
   876  	if err := validate.EnumCase(path, location, value, prefixStatusTypeLabelPropEnum, true); err != nil {
   877  		return err
   878  	}
   879  	return nil
   880  }
   881  
   882  func (m *PrefixStatus) validateLabel(formats strfmt.Registry) error {
   883  
   884  	if err := validate.Required("status"+"."+"label", "body", m.Label); err != nil {
   885  		return err
   886  	}
   887  
   888  	// value enum
   889  	if err := m.validateLabelEnum("status"+"."+"label", "body", *m.Label); err != nil {
   890  		return err
   891  	}
   892  
   893  	return nil
   894  }
   895  
   896  var prefixStatusTypeValuePropEnum []interface{}
   897  
   898  func init() {
   899  	var res []string
   900  	if err := json.Unmarshal([]byte(`["container","active","reserved","deprecated"]`), &res); err != nil {
   901  		panic(err)
   902  	}
   903  	for _, v := range res {
   904  		prefixStatusTypeValuePropEnum = append(prefixStatusTypeValuePropEnum, v)
   905  	}
   906  }
   907  
   908  const (
   909  
   910  	// PrefixStatusValueContainer captures enum value "container"
   911  	PrefixStatusValueContainer string = "container"
   912  
   913  	// PrefixStatusValueActive captures enum value "active"
   914  	PrefixStatusValueActive string = "active"
   915  
   916  	// PrefixStatusValueReserved captures enum value "reserved"
   917  	PrefixStatusValueReserved string = "reserved"
   918  
   919  	// PrefixStatusValueDeprecated captures enum value "deprecated"
   920  	PrefixStatusValueDeprecated string = "deprecated"
   921  )
   922  
   923  // prop value enum
   924  func (m *PrefixStatus) validateValueEnum(path, location string, value string) error {
   925  	if err := validate.EnumCase(path, location, value, prefixStatusTypeValuePropEnum, true); err != nil {
   926  		return err
   927  	}
   928  	return nil
   929  }
   930  
   931  func (m *PrefixStatus) validateValue(formats strfmt.Registry) error {
   932  
   933  	if err := validate.Required("status"+"."+"value", "body", m.Value); err != nil {
   934  		return err
   935  	}
   936  
   937  	// value enum
   938  	if err := m.validateValueEnum("status"+"."+"value", "body", *m.Value); err != nil {
   939  		return err
   940  	}
   941  
   942  	return nil
   943  }
   944  
   945  // ContextValidate validates this prefix status based on context it is used
   946  func (m *PrefixStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   947  	return nil
   948  }
   949  
   950  // MarshalBinary interface implementation
   951  func (m *PrefixStatus) MarshalBinary() ([]byte, error) {
   952  	if m == nil {
   953  		return nil, nil
   954  	}
   955  	return swag.WriteJSON(m)
   956  }
   957  
   958  // UnmarshalBinary interface implementation
   959  func (m *PrefixStatus) UnmarshalBinary(b []byte) error {
   960  	var res PrefixStatus
   961  	if err := swag.ReadJSON(b, &res); err != nil {
   962  		return err
   963  	}
   964  	*m = res
   965  	return nil
   966  }