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