github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_journal_entry.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  // WritableJournalEntry writable journal entry
    34  //
    35  // swagger:model WritableJournalEntry
    36  type WritableJournalEntry struct {
    37  
    38  	// Assigned object
    39  	// Read Only: true
    40  	AssignedObject map[string]*string `json:"assigned_object,omitempty"`
    41  
    42  	// Assigned object id
    43  	// Required: true
    44  	// Maximum: 2.147483647e+09
    45  	// Minimum: 0
    46  	AssignedObjectID *int64 `json:"assigned_object_id"`
    47  
    48  	// Assigned object type
    49  	// Required: true
    50  	AssignedObjectType *string `json:"assigned_object_type"`
    51  
    52  	// Comments
    53  	// Required: true
    54  	// Min Length: 1
    55  	Comments *string `json:"comments"`
    56  
    57  	// Created
    58  	// Read Only: true
    59  	// Format: date-time
    60  	Created strfmt.DateTime `json:"created,omitempty"`
    61  
    62  	// Created by
    63  	CreatedBy *int64 `json:"created_by,omitempty"`
    64  
    65  	// Display
    66  	// Read Only: true
    67  	Display string `json:"display,omitempty"`
    68  
    69  	// Id
    70  	// Read Only: true
    71  	ID int64 `json:"id,omitempty"`
    72  
    73  	// Kind
    74  	// Enum: [info success warning danger]
    75  	Kind string `json:"kind,omitempty"`
    76  
    77  	// Url
    78  	// Read Only: true
    79  	// Format: uri
    80  	URL strfmt.URI `json:"url,omitempty"`
    81  }
    82  
    83  // Validate validates this writable journal entry
    84  func (m *WritableJournalEntry) Validate(formats strfmt.Registry) error {
    85  	var res []error
    86  
    87  	if err := m.validateAssignedObjectID(formats); err != nil {
    88  		res = append(res, err)
    89  	}
    90  
    91  	if err := m.validateAssignedObjectType(formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if err := m.validateComments(formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if err := m.validateCreated(formats); err != nil {
   100  		res = append(res, err)
   101  	}
   102  
   103  	if err := m.validateKind(formats); err != nil {
   104  		res = append(res, err)
   105  	}
   106  
   107  	if err := m.validateURL(formats); err != nil {
   108  		res = append(res, err)
   109  	}
   110  
   111  	if len(res) > 0 {
   112  		return errors.CompositeValidationError(res...)
   113  	}
   114  	return nil
   115  }
   116  
   117  func (m *WritableJournalEntry) validateAssignedObjectID(formats strfmt.Registry) error {
   118  
   119  	if err := validate.Required("assigned_object_id", "body", m.AssignedObjectID); err != nil {
   120  		return err
   121  	}
   122  
   123  	if err := validate.MinimumInt("assigned_object_id", "body", *m.AssignedObjectID, 0, false); err != nil {
   124  		return err
   125  	}
   126  
   127  	if err := validate.MaximumInt("assigned_object_id", "body", *m.AssignedObjectID, 2.147483647e+09, false); err != nil {
   128  		return err
   129  	}
   130  
   131  	return nil
   132  }
   133  
   134  func (m *WritableJournalEntry) validateAssignedObjectType(formats strfmt.Registry) error {
   135  
   136  	if err := validate.Required("assigned_object_type", "body", m.AssignedObjectType); err != nil {
   137  		return err
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *WritableJournalEntry) validateComments(formats strfmt.Registry) error {
   144  
   145  	if err := validate.Required("comments", "body", m.Comments); err != nil {
   146  		return err
   147  	}
   148  
   149  	if err := validate.MinLength("comments", "body", *m.Comments, 1); err != nil {
   150  		return err
   151  	}
   152  
   153  	return nil
   154  }
   155  
   156  func (m *WritableJournalEntry) validateCreated(formats strfmt.Registry) error {
   157  	if swag.IsZero(m.Created) { // not required
   158  		return nil
   159  	}
   160  
   161  	if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil {
   162  		return err
   163  	}
   164  
   165  	return nil
   166  }
   167  
   168  var writableJournalEntryTypeKindPropEnum []interface{}
   169  
   170  func init() {
   171  	var res []string
   172  	if err := json.Unmarshal([]byte(`["info","success","warning","danger"]`), &res); err != nil {
   173  		panic(err)
   174  	}
   175  	for _, v := range res {
   176  		writableJournalEntryTypeKindPropEnum = append(writableJournalEntryTypeKindPropEnum, v)
   177  	}
   178  }
   179  
   180  const (
   181  
   182  	// WritableJournalEntryKindInfo captures enum value "info"
   183  	WritableJournalEntryKindInfo string = "info"
   184  
   185  	// WritableJournalEntryKindSuccess captures enum value "success"
   186  	WritableJournalEntryKindSuccess string = "success"
   187  
   188  	// WritableJournalEntryKindWarning captures enum value "warning"
   189  	WritableJournalEntryKindWarning string = "warning"
   190  
   191  	// WritableJournalEntryKindDanger captures enum value "danger"
   192  	WritableJournalEntryKindDanger string = "danger"
   193  )
   194  
   195  // prop value enum
   196  func (m *WritableJournalEntry) validateKindEnum(path, location string, value string) error {
   197  	if err := validate.EnumCase(path, location, value, writableJournalEntryTypeKindPropEnum, true); err != nil {
   198  		return err
   199  	}
   200  	return nil
   201  }
   202  
   203  func (m *WritableJournalEntry) validateKind(formats strfmt.Registry) error {
   204  	if swag.IsZero(m.Kind) { // not required
   205  		return nil
   206  	}
   207  
   208  	// value enum
   209  	if err := m.validateKindEnum("kind", "body", m.Kind); err != nil {
   210  		return err
   211  	}
   212  
   213  	return nil
   214  }
   215  
   216  func (m *WritableJournalEntry) validateURL(formats strfmt.Registry) error {
   217  	if swag.IsZero(m.URL) { // not required
   218  		return nil
   219  	}
   220  
   221  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   222  		return err
   223  	}
   224  
   225  	return nil
   226  }
   227  
   228  // ContextValidate validate this writable journal entry based on the context it is used
   229  func (m *WritableJournalEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   230  	var res []error
   231  
   232  	if err := m.contextValidateAssignedObject(ctx, formats); err != nil {
   233  		res = append(res, err)
   234  	}
   235  
   236  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   237  		res = append(res, err)
   238  	}
   239  
   240  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   241  		res = append(res, err)
   242  	}
   243  
   244  	if err := m.contextValidateID(ctx, formats); err != nil {
   245  		res = append(res, err)
   246  	}
   247  
   248  	if err := m.contextValidateURL(ctx, formats); err != nil {
   249  		res = append(res, err)
   250  	}
   251  
   252  	if len(res) > 0 {
   253  		return errors.CompositeValidationError(res...)
   254  	}
   255  	return nil
   256  }
   257  
   258  func (m *WritableJournalEntry) contextValidateAssignedObject(ctx context.Context, formats strfmt.Registry) error {
   259  
   260  	return nil
   261  }
   262  
   263  func (m *WritableJournalEntry) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   264  
   265  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.DateTime(m.Created)); err != nil {
   266  		return err
   267  	}
   268  
   269  	return nil
   270  }
   271  
   272  func (m *WritableJournalEntry) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   273  
   274  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   275  		return err
   276  	}
   277  
   278  	return nil
   279  }
   280  
   281  func (m *WritableJournalEntry) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   282  
   283  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   284  		return err
   285  	}
   286  
   287  	return nil
   288  }
   289  
   290  func (m *WritableJournalEntry) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   291  
   292  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   293  		return err
   294  	}
   295  
   296  	return nil
   297  }
   298  
   299  // MarshalBinary interface implementation
   300  func (m *WritableJournalEntry) MarshalBinary() ([]byte, error) {
   301  	if m == nil {
   302  		return nil, nil
   303  	}
   304  	return swag.WriteJSON(m)
   305  }
   306  
   307  // UnmarshalBinary interface implementation
   308  func (m *WritableJournalEntry) UnmarshalBinary(b []byte) error {
   309  	var res WritableJournalEntry
   310  	if err := swag.ReadJSON(b, &res); err != nil {
   311  		return err
   312  	}
   313  	*m = res
   314  	return nil
   315  }