...

Source file src/github.com/sigstore/rekor/pkg/generated/models/rekord_v001_schema.go

Documentation: github.com/sigstore/rekor/pkg/generated/models

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  //
     4  // Copyright 2021 The Sigstore Authors.
     5  //
     6  // Licensed under the Apache License, Version 2.0 (the "License");
     7  // you may not use this file except in compliance with the License.
     8  // You may obtain a copy of the License at
     9  //
    10  //     http://www.apache.org/licenses/LICENSE-2.0
    11  //
    12  // Unless required by applicable law or agreed to in writing, software
    13  // distributed under the License is distributed on an "AS IS" BASIS,
    14  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  // See the License for the specific language governing permissions and
    16  // limitations under the License.
    17  //
    18  
    19  package models
    20  
    21  // This file was generated by the swagger tool.
    22  // Editing this file might prove futile when you re-run the swagger generate command
    23  
    24  import (
    25  	"context"
    26  	"encoding/json"
    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  // RekordV001Schema Rekor v0.0.1 Schema
    35  //
    36  // # Schema for Rekord object
    37  //
    38  // swagger:model rekordV001Schema
    39  type RekordV001Schema struct {
    40  
    41  	// data
    42  	// Required: true
    43  	Data *RekordV001SchemaData `json:"data"`
    44  
    45  	// signature
    46  	// Required: true
    47  	Signature *RekordV001SchemaSignature `json:"signature"`
    48  }
    49  
    50  // Validate validates this rekord v001 schema
    51  func (m *RekordV001Schema) Validate(formats strfmt.Registry) error {
    52  	var res []error
    53  
    54  	if err := m.validateData(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if err := m.validateSignature(formats); err != nil {
    59  		res = append(res, err)
    60  	}
    61  
    62  	if len(res) > 0 {
    63  		return errors.CompositeValidationError(res...)
    64  	}
    65  	return nil
    66  }
    67  
    68  func (m *RekordV001Schema) validateData(formats strfmt.Registry) error {
    69  
    70  	if err := validate.Required("data", "body", m.Data); err != nil {
    71  		return err
    72  	}
    73  
    74  	if m.Data != nil {
    75  		if err := m.Data.Validate(formats); err != nil {
    76  			if ve, ok := err.(*errors.Validation); ok {
    77  				return ve.ValidateName("data")
    78  			} else if ce, ok := err.(*errors.CompositeError); ok {
    79  				return ce.ValidateName("data")
    80  			}
    81  			return err
    82  		}
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  func (m *RekordV001Schema) validateSignature(formats strfmt.Registry) error {
    89  
    90  	if err := validate.Required("signature", "body", m.Signature); err != nil {
    91  		return err
    92  	}
    93  
    94  	if m.Signature != nil {
    95  		if err := m.Signature.Validate(formats); err != nil {
    96  			if ve, ok := err.(*errors.Validation); ok {
    97  				return ve.ValidateName("signature")
    98  			} else if ce, ok := err.(*errors.CompositeError); ok {
    99  				return ce.ValidateName("signature")
   100  			}
   101  			return err
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  // ContextValidate validate this rekord v001 schema based on the context it is used
   109  func (m *RekordV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   110  	var res []error
   111  
   112  	if err := m.contextValidateData(ctx, formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.contextValidateSignature(ctx, 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 *RekordV001Schema) contextValidateData(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if m.Data != nil {
   129  
   130  		if err := m.Data.ContextValidate(ctx, formats); err != nil {
   131  			if ve, ok := err.(*errors.Validation); ok {
   132  				return ve.ValidateName("data")
   133  			} else if ce, ok := err.(*errors.CompositeError); ok {
   134  				return ce.ValidateName("data")
   135  			}
   136  			return err
   137  		}
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *RekordV001Schema) contextValidateSignature(ctx context.Context, formats strfmt.Registry) error {
   144  
   145  	if m.Signature != nil {
   146  
   147  		if err := m.Signature.ContextValidate(ctx, formats); err != nil {
   148  			if ve, ok := err.(*errors.Validation); ok {
   149  				return ve.ValidateName("signature")
   150  			} else if ce, ok := err.(*errors.CompositeError); ok {
   151  				return ce.ValidateName("signature")
   152  			}
   153  			return err
   154  		}
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  // MarshalBinary interface implementation
   161  func (m *RekordV001Schema) MarshalBinary() ([]byte, error) {
   162  	if m == nil {
   163  		return nil, nil
   164  	}
   165  	return swag.WriteJSON(m)
   166  }
   167  
   168  // UnmarshalBinary interface implementation
   169  func (m *RekordV001Schema) UnmarshalBinary(b []byte) error {
   170  	var res RekordV001Schema
   171  	if err := swag.ReadJSON(b, &res); err != nil {
   172  		return err
   173  	}
   174  	*m = res
   175  	return nil
   176  }
   177  
   178  // RekordV001SchemaData Information about the content associated with the entry
   179  //
   180  // swagger:model RekordV001SchemaData
   181  type RekordV001SchemaData struct {
   182  
   183  	// Specifies the content inline within the document
   184  	// Format: byte
   185  	Content strfmt.Base64 `json:"content,omitempty"`
   186  
   187  	// hash
   188  	Hash *RekordV001SchemaDataHash `json:"hash,omitempty"`
   189  }
   190  
   191  // Validate validates this rekord v001 schema data
   192  func (m *RekordV001SchemaData) Validate(formats strfmt.Registry) error {
   193  	var res []error
   194  
   195  	if err := m.validateHash(formats); err != nil {
   196  		res = append(res, err)
   197  	}
   198  
   199  	if len(res) > 0 {
   200  		return errors.CompositeValidationError(res...)
   201  	}
   202  	return nil
   203  }
   204  
   205  func (m *RekordV001SchemaData) validateHash(formats strfmt.Registry) error {
   206  	if swag.IsZero(m.Hash) { // not required
   207  		return nil
   208  	}
   209  
   210  	if m.Hash != nil {
   211  		if err := m.Hash.Validate(formats); err != nil {
   212  			if ve, ok := err.(*errors.Validation); ok {
   213  				return ve.ValidateName("data" + "." + "hash")
   214  			} else if ce, ok := err.(*errors.CompositeError); ok {
   215  				return ce.ValidateName("data" + "." + "hash")
   216  			}
   217  			return err
   218  		}
   219  	}
   220  
   221  	return nil
   222  }
   223  
   224  // ContextValidate validate this rekord v001 schema data based on the context it is used
   225  func (m *RekordV001SchemaData) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   226  	var res []error
   227  
   228  	if err := m.contextValidateHash(ctx, formats); err != nil {
   229  		res = append(res, err)
   230  	}
   231  
   232  	if len(res) > 0 {
   233  		return errors.CompositeValidationError(res...)
   234  	}
   235  	return nil
   236  }
   237  
   238  func (m *RekordV001SchemaData) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
   239  
   240  	if m.Hash != nil {
   241  
   242  		if swag.IsZero(m.Hash) { // not required
   243  			return nil
   244  		}
   245  
   246  		if err := m.Hash.ContextValidate(ctx, formats); err != nil {
   247  			if ve, ok := err.(*errors.Validation); ok {
   248  				return ve.ValidateName("data" + "." + "hash")
   249  			} else if ce, ok := err.(*errors.CompositeError); ok {
   250  				return ce.ValidateName("data" + "." + "hash")
   251  			}
   252  			return err
   253  		}
   254  	}
   255  
   256  	return nil
   257  }
   258  
   259  // MarshalBinary interface implementation
   260  func (m *RekordV001SchemaData) MarshalBinary() ([]byte, error) {
   261  	if m == nil {
   262  		return nil, nil
   263  	}
   264  	return swag.WriteJSON(m)
   265  }
   266  
   267  // UnmarshalBinary interface implementation
   268  func (m *RekordV001SchemaData) UnmarshalBinary(b []byte) error {
   269  	var res RekordV001SchemaData
   270  	if err := swag.ReadJSON(b, &res); err != nil {
   271  		return err
   272  	}
   273  	*m = res
   274  	return nil
   275  }
   276  
   277  // RekordV001SchemaDataHash Specifies the hash algorithm and value for the content
   278  //
   279  // swagger:model RekordV001SchemaDataHash
   280  type RekordV001SchemaDataHash struct {
   281  
   282  	// The hashing function used to compute the hash value
   283  	// Required: true
   284  	// Enum: [sha256]
   285  	Algorithm *string `json:"algorithm"`
   286  
   287  	// The hash value for the content
   288  	// Required: true
   289  	Value *string `json:"value"`
   290  }
   291  
   292  // Validate validates this rekord v001 schema data hash
   293  func (m *RekordV001SchemaDataHash) Validate(formats strfmt.Registry) error {
   294  	var res []error
   295  
   296  	if err := m.validateAlgorithm(formats); err != nil {
   297  		res = append(res, err)
   298  	}
   299  
   300  	if err := m.validateValue(formats); err != nil {
   301  		res = append(res, err)
   302  	}
   303  
   304  	if len(res) > 0 {
   305  		return errors.CompositeValidationError(res...)
   306  	}
   307  	return nil
   308  }
   309  
   310  var rekordV001SchemaDataHashTypeAlgorithmPropEnum []interface{}
   311  
   312  func init() {
   313  	var res []string
   314  	if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
   315  		panic(err)
   316  	}
   317  	for _, v := range res {
   318  		rekordV001SchemaDataHashTypeAlgorithmPropEnum = append(rekordV001SchemaDataHashTypeAlgorithmPropEnum, v)
   319  	}
   320  }
   321  
   322  const (
   323  
   324  	// RekordV001SchemaDataHashAlgorithmSha256 captures enum value "sha256"
   325  	RekordV001SchemaDataHashAlgorithmSha256 string = "sha256"
   326  )
   327  
   328  // prop value enum
   329  func (m *RekordV001SchemaDataHash) validateAlgorithmEnum(path, location string, value string) error {
   330  	if err := validate.EnumCase(path, location, value, rekordV001SchemaDataHashTypeAlgorithmPropEnum, true); err != nil {
   331  		return err
   332  	}
   333  	return nil
   334  }
   335  
   336  func (m *RekordV001SchemaDataHash) validateAlgorithm(formats strfmt.Registry) error {
   337  
   338  	if err := validate.Required("data"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
   339  		return err
   340  	}
   341  
   342  	// value enum
   343  	if err := m.validateAlgorithmEnum("data"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
   344  		return err
   345  	}
   346  
   347  	return nil
   348  }
   349  
   350  func (m *RekordV001SchemaDataHash) validateValue(formats strfmt.Registry) error {
   351  
   352  	if err := validate.Required("data"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
   353  		return err
   354  	}
   355  
   356  	return nil
   357  }
   358  
   359  // ContextValidate validate this rekord v001 schema data hash based on the context it is used
   360  func (m *RekordV001SchemaDataHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   361  	var res []error
   362  
   363  	if len(res) > 0 {
   364  		return errors.CompositeValidationError(res...)
   365  	}
   366  	return nil
   367  }
   368  
   369  // MarshalBinary interface implementation
   370  func (m *RekordV001SchemaDataHash) MarshalBinary() ([]byte, error) {
   371  	if m == nil {
   372  		return nil, nil
   373  	}
   374  	return swag.WriteJSON(m)
   375  }
   376  
   377  // UnmarshalBinary interface implementation
   378  func (m *RekordV001SchemaDataHash) UnmarshalBinary(b []byte) error {
   379  	var res RekordV001SchemaDataHash
   380  	if err := swag.ReadJSON(b, &res); err != nil {
   381  		return err
   382  	}
   383  	*m = res
   384  	return nil
   385  }
   386  
   387  // RekordV001SchemaSignature Information about the detached signature associated with the entry
   388  //
   389  // swagger:model RekordV001SchemaSignature
   390  type RekordV001SchemaSignature struct {
   391  
   392  	// Specifies the content of the signature inline within the document
   393  	// Required: true
   394  	// Format: byte
   395  	Content *strfmt.Base64 `json:"content"`
   396  
   397  	// Specifies the format of the signature
   398  	// Required: true
   399  	// Enum: [pgp minisign x509 ssh]
   400  	Format *string `json:"format"`
   401  
   402  	// public key
   403  	// Required: true
   404  	PublicKey *RekordV001SchemaSignaturePublicKey `json:"publicKey"`
   405  }
   406  
   407  // Validate validates this rekord v001 schema signature
   408  func (m *RekordV001SchemaSignature) Validate(formats strfmt.Registry) error {
   409  	var res []error
   410  
   411  	if err := m.validateContent(formats); err != nil {
   412  		res = append(res, err)
   413  	}
   414  
   415  	if err := m.validateFormat(formats); err != nil {
   416  		res = append(res, err)
   417  	}
   418  
   419  	if err := m.validatePublicKey(formats); err != nil {
   420  		res = append(res, err)
   421  	}
   422  
   423  	if len(res) > 0 {
   424  		return errors.CompositeValidationError(res...)
   425  	}
   426  	return nil
   427  }
   428  
   429  func (m *RekordV001SchemaSignature) validateContent(formats strfmt.Registry) error {
   430  
   431  	if err := validate.Required("signature"+"."+"content", "body", m.Content); err != nil {
   432  		return err
   433  	}
   434  
   435  	return nil
   436  }
   437  
   438  var rekordV001SchemaSignatureTypeFormatPropEnum []interface{}
   439  
   440  func init() {
   441  	var res []string
   442  	if err := json.Unmarshal([]byte(`["pgp","minisign","x509","ssh"]`), &res); err != nil {
   443  		panic(err)
   444  	}
   445  	for _, v := range res {
   446  		rekordV001SchemaSignatureTypeFormatPropEnum = append(rekordV001SchemaSignatureTypeFormatPropEnum, v)
   447  	}
   448  }
   449  
   450  const (
   451  
   452  	// RekordV001SchemaSignatureFormatPgp captures enum value "pgp"
   453  	RekordV001SchemaSignatureFormatPgp string = "pgp"
   454  
   455  	// RekordV001SchemaSignatureFormatMinisign captures enum value "minisign"
   456  	RekordV001SchemaSignatureFormatMinisign string = "minisign"
   457  
   458  	// RekordV001SchemaSignatureFormatX509 captures enum value "x509"
   459  	RekordV001SchemaSignatureFormatX509 string = "x509"
   460  
   461  	// RekordV001SchemaSignatureFormatSSH captures enum value "ssh"
   462  	RekordV001SchemaSignatureFormatSSH string = "ssh"
   463  )
   464  
   465  // prop value enum
   466  func (m *RekordV001SchemaSignature) validateFormatEnum(path, location string, value string) error {
   467  	if err := validate.EnumCase(path, location, value, rekordV001SchemaSignatureTypeFormatPropEnum, true); err != nil {
   468  		return err
   469  	}
   470  	return nil
   471  }
   472  
   473  func (m *RekordV001SchemaSignature) validateFormat(formats strfmt.Registry) error {
   474  
   475  	if err := validate.Required("signature"+"."+"format", "body", m.Format); err != nil {
   476  		return err
   477  	}
   478  
   479  	// value enum
   480  	if err := m.validateFormatEnum("signature"+"."+"format", "body", *m.Format); err != nil {
   481  		return err
   482  	}
   483  
   484  	return nil
   485  }
   486  
   487  func (m *RekordV001SchemaSignature) validatePublicKey(formats strfmt.Registry) error {
   488  
   489  	if err := validate.Required("signature"+"."+"publicKey", "body", m.PublicKey); err != nil {
   490  		return err
   491  	}
   492  
   493  	if m.PublicKey != nil {
   494  		if err := m.PublicKey.Validate(formats); err != nil {
   495  			if ve, ok := err.(*errors.Validation); ok {
   496  				return ve.ValidateName("signature" + "." + "publicKey")
   497  			} else if ce, ok := err.(*errors.CompositeError); ok {
   498  				return ce.ValidateName("signature" + "." + "publicKey")
   499  			}
   500  			return err
   501  		}
   502  	}
   503  
   504  	return nil
   505  }
   506  
   507  // ContextValidate validate this rekord v001 schema signature based on the context it is used
   508  func (m *RekordV001SchemaSignature) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   509  	var res []error
   510  
   511  	if err := m.contextValidatePublicKey(ctx, formats); err != nil {
   512  		res = append(res, err)
   513  	}
   514  
   515  	if len(res) > 0 {
   516  		return errors.CompositeValidationError(res...)
   517  	}
   518  	return nil
   519  }
   520  
   521  func (m *RekordV001SchemaSignature) contextValidatePublicKey(ctx context.Context, formats strfmt.Registry) error {
   522  
   523  	if m.PublicKey != nil {
   524  
   525  		if err := m.PublicKey.ContextValidate(ctx, formats); err != nil {
   526  			if ve, ok := err.(*errors.Validation); ok {
   527  				return ve.ValidateName("signature" + "." + "publicKey")
   528  			} else if ce, ok := err.(*errors.CompositeError); ok {
   529  				return ce.ValidateName("signature" + "." + "publicKey")
   530  			}
   531  			return err
   532  		}
   533  	}
   534  
   535  	return nil
   536  }
   537  
   538  // MarshalBinary interface implementation
   539  func (m *RekordV001SchemaSignature) MarshalBinary() ([]byte, error) {
   540  	if m == nil {
   541  		return nil, nil
   542  	}
   543  	return swag.WriteJSON(m)
   544  }
   545  
   546  // UnmarshalBinary interface implementation
   547  func (m *RekordV001SchemaSignature) UnmarshalBinary(b []byte) error {
   548  	var res RekordV001SchemaSignature
   549  	if err := swag.ReadJSON(b, &res); err != nil {
   550  		return err
   551  	}
   552  	*m = res
   553  	return nil
   554  }
   555  
   556  // RekordV001SchemaSignaturePublicKey The public key that can verify the signature
   557  //
   558  // swagger:model RekordV001SchemaSignaturePublicKey
   559  type RekordV001SchemaSignaturePublicKey struct {
   560  
   561  	// Specifies the content of the public key inline within the document
   562  	// Required: true
   563  	// Format: byte
   564  	Content *strfmt.Base64 `json:"content"`
   565  }
   566  
   567  // Validate validates this rekord v001 schema signature public key
   568  func (m *RekordV001SchemaSignaturePublicKey) Validate(formats strfmt.Registry) error {
   569  	var res []error
   570  
   571  	if err := m.validateContent(formats); err != nil {
   572  		res = append(res, err)
   573  	}
   574  
   575  	if len(res) > 0 {
   576  		return errors.CompositeValidationError(res...)
   577  	}
   578  	return nil
   579  }
   580  
   581  func (m *RekordV001SchemaSignaturePublicKey) validateContent(formats strfmt.Registry) error {
   582  
   583  	if err := validate.Required("signature"+"."+"publicKey"+"."+"content", "body", m.Content); err != nil {
   584  		return err
   585  	}
   586  
   587  	return nil
   588  }
   589  
   590  // ContextValidate validates this rekord v001 schema signature public key based on context it is used
   591  func (m *RekordV001SchemaSignaturePublicKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   592  	return nil
   593  }
   594  
   595  // MarshalBinary interface implementation
   596  func (m *RekordV001SchemaSignaturePublicKey) MarshalBinary() ([]byte, error) {
   597  	if m == nil {
   598  		return nil, nil
   599  	}
   600  	return swag.WriteJSON(m)
   601  }
   602  
   603  // UnmarshalBinary interface implementation
   604  func (m *RekordV001SchemaSignaturePublicKey) UnmarshalBinary(b []byte) error {
   605  	var res RekordV001SchemaSignaturePublicKey
   606  	if err := swag.ReadJSON(b, &res); err != nil {
   607  		return err
   608  	}
   609  	*m = res
   610  	return nil
   611  }
   612  

View as plain text