github.com/digitalocean/go-netbox@v0.0.2/netbox/models/job_result.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  
    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  // JobResult job result
    34  //
    35  // swagger:model JobResult
    36  type JobResult struct {
    37  
    38  	// Completed
    39  	// Format: date-time
    40  	Completed *strfmt.DateTime `json:"completed,omitempty"`
    41  
    42  	// Created
    43  	// Read Only: true
    44  	// Format: date-time
    45  	Created strfmt.DateTime `json:"created,omitempty"`
    46  
    47  	// Data
    48  	Data *string `json:"data,omitempty"`
    49  
    50  	// Display
    51  	// Read Only: true
    52  	Display string `json:"display,omitempty"`
    53  
    54  	// Id
    55  	// Read Only: true
    56  	ID int64 `json:"id,omitempty"`
    57  
    58  	// Job id
    59  	// Required: true
    60  	// Format: uuid
    61  	JobID *strfmt.UUID `json:"job_id"`
    62  
    63  	// Name
    64  	// Required: true
    65  	// Max Length: 255
    66  	// Min Length: 1
    67  	Name *string `json:"name"`
    68  
    69  	// Obj type
    70  	// Read Only: true
    71  	ObjType string `json:"obj_type,omitempty"`
    72  
    73  	// status
    74  	Status *JobResultStatus `json:"status,omitempty"`
    75  
    76  	// Url
    77  	// Read Only: true
    78  	// Format: uri
    79  	URL strfmt.URI `json:"url,omitempty"`
    80  
    81  	// user
    82  	User *NestedUser `json:"user,omitempty"`
    83  }
    84  
    85  // Validate validates this job result
    86  func (m *JobResult) Validate(formats strfmt.Registry) error {
    87  	var res []error
    88  
    89  	if err := m.validateCompleted(formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if err := m.validateCreated(formats); err != nil {
    94  		res = append(res, err)
    95  	}
    96  
    97  	if err := m.validateJobID(formats); err != nil {
    98  		res = append(res, err)
    99  	}
   100  
   101  	if err := m.validateName(formats); err != nil {
   102  		res = append(res, err)
   103  	}
   104  
   105  	if err := m.validateStatus(formats); err != nil {
   106  		res = append(res, err)
   107  	}
   108  
   109  	if err := m.validateURL(formats); err != nil {
   110  		res = append(res, err)
   111  	}
   112  
   113  	if err := m.validateUser(formats); err != nil {
   114  		res = append(res, err)
   115  	}
   116  
   117  	if len(res) > 0 {
   118  		return errors.CompositeValidationError(res...)
   119  	}
   120  	return nil
   121  }
   122  
   123  func (m *JobResult) validateCompleted(formats strfmt.Registry) error {
   124  	if swag.IsZero(m.Completed) { // not required
   125  		return nil
   126  	}
   127  
   128  	if err := validate.FormatOf("completed", "body", "date-time", m.Completed.String(), formats); err != nil {
   129  		return err
   130  	}
   131  
   132  	return nil
   133  }
   134  
   135  func (m *JobResult) validateCreated(formats strfmt.Registry) error {
   136  	if swag.IsZero(m.Created) { // not required
   137  		return nil
   138  	}
   139  
   140  	if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil {
   141  		return err
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  func (m *JobResult) validateJobID(formats strfmt.Registry) error {
   148  
   149  	if err := validate.Required("job_id", "body", m.JobID); err != nil {
   150  		return err
   151  	}
   152  
   153  	if err := validate.FormatOf("job_id", "body", "uuid", m.JobID.String(), formats); err != nil {
   154  		return err
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  func (m *JobResult) 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, 255); err != nil {
   171  		return err
   172  	}
   173  
   174  	return nil
   175  }
   176  
   177  func (m *JobResult) validateStatus(formats strfmt.Registry) error {
   178  	if swag.IsZero(m.Status) { // not required
   179  		return nil
   180  	}
   181  
   182  	if m.Status != nil {
   183  		if err := m.Status.Validate(formats); err != nil {
   184  			if ve, ok := err.(*errors.Validation); ok {
   185  				return ve.ValidateName("status")
   186  			} else if ce, ok := err.(*errors.CompositeError); ok {
   187  				return ce.ValidateName("status")
   188  			}
   189  			return err
   190  		}
   191  	}
   192  
   193  	return nil
   194  }
   195  
   196  func (m *JobResult) validateURL(formats strfmt.Registry) error {
   197  	if swag.IsZero(m.URL) { // not required
   198  		return nil
   199  	}
   200  
   201  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   202  		return err
   203  	}
   204  
   205  	return nil
   206  }
   207  
   208  func (m *JobResult) validateUser(formats strfmt.Registry) error {
   209  	if swag.IsZero(m.User) { // not required
   210  		return nil
   211  	}
   212  
   213  	if m.User != nil {
   214  		if err := m.User.Validate(formats); err != nil {
   215  			if ve, ok := err.(*errors.Validation); ok {
   216  				return ve.ValidateName("user")
   217  			} else if ce, ok := err.(*errors.CompositeError); ok {
   218  				return ce.ValidateName("user")
   219  			}
   220  			return err
   221  		}
   222  	}
   223  
   224  	return nil
   225  }
   226  
   227  // ContextValidate validate this job result based on the context it is used
   228  func (m *JobResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   229  	var res []error
   230  
   231  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   232  		res = append(res, err)
   233  	}
   234  
   235  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   236  		res = append(res, err)
   237  	}
   238  
   239  	if err := m.contextValidateID(ctx, formats); err != nil {
   240  		res = append(res, err)
   241  	}
   242  
   243  	if err := m.contextValidateObjType(ctx, formats); err != nil {
   244  		res = append(res, err)
   245  	}
   246  
   247  	if err := m.contextValidateStatus(ctx, formats); err != nil {
   248  		res = append(res, err)
   249  	}
   250  
   251  	if err := m.contextValidateURL(ctx, formats); err != nil {
   252  		res = append(res, err)
   253  	}
   254  
   255  	if err := m.contextValidateUser(ctx, formats); err != nil {
   256  		res = append(res, err)
   257  	}
   258  
   259  	if len(res) > 0 {
   260  		return errors.CompositeValidationError(res...)
   261  	}
   262  	return nil
   263  }
   264  
   265  func (m *JobResult) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   266  
   267  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.DateTime(m.Created)); err != nil {
   268  		return err
   269  	}
   270  
   271  	return nil
   272  }
   273  
   274  func (m *JobResult) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   275  
   276  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   277  		return err
   278  	}
   279  
   280  	return nil
   281  }
   282  
   283  func (m *JobResult) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   284  
   285  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   286  		return err
   287  	}
   288  
   289  	return nil
   290  }
   291  
   292  func (m *JobResult) contextValidateObjType(ctx context.Context, formats strfmt.Registry) error {
   293  
   294  	if err := validate.ReadOnly(ctx, "obj_type", "body", string(m.ObjType)); err != nil {
   295  		return err
   296  	}
   297  
   298  	return nil
   299  }
   300  
   301  func (m *JobResult) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {
   302  
   303  	if m.Status != nil {
   304  		if err := m.Status.ContextValidate(ctx, formats); err != nil {
   305  			if ve, ok := err.(*errors.Validation); ok {
   306  				return ve.ValidateName("status")
   307  			} else if ce, ok := err.(*errors.CompositeError); ok {
   308  				return ce.ValidateName("status")
   309  			}
   310  			return err
   311  		}
   312  	}
   313  
   314  	return nil
   315  }
   316  
   317  func (m *JobResult) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   318  
   319  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   320  		return err
   321  	}
   322  
   323  	return nil
   324  }
   325  
   326  func (m *JobResult) contextValidateUser(ctx context.Context, formats strfmt.Registry) error {
   327  
   328  	if m.User != nil {
   329  		if err := m.User.ContextValidate(ctx, formats); err != nil {
   330  			if ve, ok := err.(*errors.Validation); ok {
   331  				return ve.ValidateName("user")
   332  			} else if ce, ok := err.(*errors.CompositeError); ok {
   333  				return ce.ValidateName("user")
   334  			}
   335  			return err
   336  		}
   337  	}
   338  
   339  	return nil
   340  }
   341  
   342  // MarshalBinary interface implementation
   343  func (m *JobResult) MarshalBinary() ([]byte, error) {
   344  	if m == nil {
   345  		return nil, nil
   346  	}
   347  	return swag.WriteJSON(m)
   348  }
   349  
   350  // UnmarshalBinary interface implementation
   351  func (m *JobResult) UnmarshalBinary(b []byte) error {
   352  	var res JobResult
   353  	if err := swag.ReadJSON(b, &res); err != nil {
   354  		return err
   355  	}
   356  	*m = res
   357  	return nil
   358  }
   359  
   360  // JobResultStatus Status
   361  //
   362  // swagger:model JobResultStatus
   363  type JobResultStatus struct {
   364  
   365  	// label
   366  	// Required: true
   367  	// Enum: [Pending Running Completed Errored Failed]
   368  	Label *string `json:"label"`
   369  
   370  	// value
   371  	// Required: true
   372  	// Enum: [pending running completed errored failed]
   373  	Value *string `json:"value"`
   374  }
   375  
   376  // Validate validates this job result status
   377  func (m *JobResultStatus) Validate(formats strfmt.Registry) error {
   378  	var res []error
   379  
   380  	if err := m.validateLabel(formats); err != nil {
   381  		res = append(res, err)
   382  	}
   383  
   384  	if err := m.validateValue(formats); err != nil {
   385  		res = append(res, err)
   386  	}
   387  
   388  	if len(res) > 0 {
   389  		return errors.CompositeValidationError(res...)
   390  	}
   391  	return nil
   392  }
   393  
   394  var jobResultStatusTypeLabelPropEnum []interface{}
   395  
   396  func init() {
   397  	var res []string
   398  	if err := json.Unmarshal([]byte(`["Pending","Running","Completed","Errored","Failed"]`), &res); err != nil {
   399  		panic(err)
   400  	}
   401  	for _, v := range res {
   402  		jobResultStatusTypeLabelPropEnum = append(jobResultStatusTypeLabelPropEnum, v)
   403  	}
   404  }
   405  
   406  const (
   407  
   408  	// JobResultStatusLabelPending captures enum value "Pending"
   409  	JobResultStatusLabelPending string = "Pending"
   410  
   411  	// JobResultStatusLabelRunning captures enum value "Running"
   412  	JobResultStatusLabelRunning string = "Running"
   413  
   414  	// JobResultStatusLabelCompleted captures enum value "Completed"
   415  	JobResultStatusLabelCompleted string = "Completed"
   416  
   417  	// JobResultStatusLabelErrored captures enum value "Errored"
   418  	JobResultStatusLabelErrored string = "Errored"
   419  
   420  	// JobResultStatusLabelFailed captures enum value "Failed"
   421  	JobResultStatusLabelFailed string = "Failed"
   422  )
   423  
   424  // prop value enum
   425  func (m *JobResultStatus) validateLabelEnum(path, location string, value string) error {
   426  	if err := validate.EnumCase(path, location, value, jobResultStatusTypeLabelPropEnum, true); err != nil {
   427  		return err
   428  	}
   429  	return nil
   430  }
   431  
   432  func (m *JobResultStatus) validateLabel(formats strfmt.Registry) error {
   433  
   434  	if err := validate.Required("status"+"."+"label", "body", m.Label); err != nil {
   435  		return err
   436  	}
   437  
   438  	// value enum
   439  	if err := m.validateLabelEnum("status"+"."+"label", "body", *m.Label); err != nil {
   440  		return err
   441  	}
   442  
   443  	return nil
   444  }
   445  
   446  var jobResultStatusTypeValuePropEnum []interface{}
   447  
   448  func init() {
   449  	var res []string
   450  	if err := json.Unmarshal([]byte(`["pending","running","completed","errored","failed"]`), &res); err != nil {
   451  		panic(err)
   452  	}
   453  	for _, v := range res {
   454  		jobResultStatusTypeValuePropEnum = append(jobResultStatusTypeValuePropEnum, v)
   455  	}
   456  }
   457  
   458  const (
   459  
   460  	// JobResultStatusValuePending captures enum value "pending"
   461  	JobResultStatusValuePending string = "pending"
   462  
   463  	// JobResultStatusValueRunning captures enum value "running"
   464  	JobResultStatusValueRunning string = "running"
   465  
   466  	// JobResultStatusValueCompleted captures enum value "completed"
   467  	JobResultStatusValueCompleted string = "completed"
   468  
   469  	// JobResultStatusValueErrored captures enum value "errored"
   470  	JobResultStatusValueErrored string = "errored"
   471  
   472  	// JobResultStatusValueFailed captures enum value "failed"
   473  	JobResultStatusValueFailed string = "failed"
   474  )
   475  
   476  // prop value enum
   477  func (m *JobResultStatus) validateValueEnum(path, location string, value string) error {
   478  	if err := validate.EnumCase(path, location, value, jobResultStatusTypeValuePropEnum, true); err != nil {
   479  		return err
   480  	}
   481  	return nil
   482  }
   483  
   484  func (m *JobResultStatus) validateValue(formats strfmt.Registry) error {
   485  
   486  	if err := validate.Required("status"+"."+"value", "body", m.Value); err != nil {
   487  		return err
   488  	}
   489  
   490  	// value enum
   491  	if err := m.validateValueEnum("status"+"."+"value", "body", *m.Value); err != nil {
   492  		return err
   493  	}
   494  
   495  	return nil
   496  }
   497  
   498  // ContextValidate validate this job result status based on the context it is used
   499  func (m *JobResultStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   500  	var res []error
   501  
   502  	if len(res) > 0 {
   503  		return errors.CompositeValidationError(res...)
   504  	}
   505  	return nil
   506  }
   507  
   508  // MarshalBinary interface implementation
   509  func (m *JobResultStatus) MarshalBinary() ([]byte, error) {
   510  	if m == nil {
   511  		return nil, nil
   512  	}
   513  	return swag.WriteJSON(m)
   514  }
   515  
   516  // UnmarshalBinary interface implementation
   517  func (m *JobResultStatus) UnmarshalBinary(b []byte) error {
   518  	var res JobResultStatus
   519  	if err := swag.ReadJSON(b, &res); err != nil {
   520  		return err
   521  	}
   522  	*m = res
   523  	return nil
   524  }