...

Source file src/github.com/sigstore/rekor/pkg/generated/models/tuf_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  
    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  // TUFV001Schema TUF v0.0.1 Schema
    34  //
    35  // # Schema for TUF metadata entries
    36  //
    37  // swagger:model tufV001Schema
    38  type TUFV001Schema struct {
    39  
    40  	// metadata
    41  	// Required: true
    42  	Metadata *TUFV001SchemaMetadata `json:"metadata"`
    43  
    44  	// root
    45  	// Required: true
    46  	Root *TUFV001SchemaRoot `json:"root"`
    47  
    48  	// TUF specification version
    49  	// Read Only: true
    50  	SpecVersion string `json:"spec_version,omitempty"`
    51  }
    52  
    53  // Validate validates this tuf v001 schema
    54  func (m *TUFV001Schema) Validate(formats strfmt.Registry) error {
    55  	var res []error
    56  
    57  	if err := m.validateMetadata(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateRoot(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if len(res) > 0 {
    66  		return errors.CompositeValidationError(res...)
    67  	}
    68  	return nil
    69  }
    70  
    71  func (m *TUFV001Schema) validateMetadata(formats strfmt.Registry) error {
    72  
    73  	if err := validate.Required("metadata", "body", m.Metadata); err != nil {
    74  		return err
    75  	}
    76  
    77  	if m.Metadata != nil {
    78  		if err := m.Metadata.Validate(formats); err != nil {
    79  			if ve, ok := err.(*errors.Validation); ok {
    80  				return ve.ValidateName("metadata")
    81  			} else if ce, ok := err.(*errors.CompositeError); ok {
    82  				return ce.ValidateName("metadata")
    83  			}
    84  			return err
    85  		}
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  func (m *TUFV001Schema) validateRoot(formats strfmt.Registry) error {
    92  
    93  	if err := validate.Required("root", "body", m.Root); err != nil {
    94  		return err
    95  	}
    96  
    97  	if m.Root != nil {
    98  		if err := m.Root.Validate(formats); err != nil {
    99  			if ve, ok := err.(*errors.Validation); ok {
   100  				return ve.ValidateName("root")
   101  			} else if ce, ok := err.(*errors.CompositeError); ok {
   102  				return ce.ValidateName("root")
   103  			}
   104  			return err
   105  		}
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  // ContextValidate validate this tuf v001 schema based on the context it is used
   112  func (m *TUFV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   113  	var res []error
   114  
   115  	if err := m.contextValidateMetadata(ctx, formats); err != nil {
   116  		res = append(res, err)
   117  	}
   118  
   119  	if err := m.contextValidateRoot(ctx, formats); err != nil {
   120  		res = append(res, err)
   121  	}
   122  
   123  	if err := m.contextValidateSpecVersion(ctx, formats); err != nil {
   124  		res = append(res, err)
   125  	}
   126  
   127  	if len(res) > 0 {
   128  		return errors.CompositeValidationError(res...)
   129  	}
   130  	return nil
   131  }
   132  
   133  func (m *TUFV001Schema) contextValidateMetadata(ctx context.Context, formats strfmt.Registry) error {
   134  
   135  	if m.Metadata != nil {
   136  
   137  		if err := m.Metadata.ContextValidate(ctx, formats); err != nil {
   138  			if ve, ok := err.(*errors.Validation); ok {
   139  				return ve.ValidateName("metadata")
   140  			} else if ce, ok := err.(*errors.CompositeError); ok {
   141  				return ce.ValidateName("metadata")
   142  			}
   143  			return err
   144  		}
   145  	}
   146  
   147  	return nil
   148  }
   149  
   150  func (m *TUFV001Schema) contextValidateRoot(ctx context.Context, formats strfmt.Registry) error {
   151  
   152  	if m.Root != nil {
   153  
   154  		if err := m.Root.ContextValidate(ctx, formats); err != nil {
   155  			if ve, ok := err.(*errors.Validation); ok {
   156  				return ve.ValidateName("root")
   157  			} else if ce, ok := err.(*errors.CompositeError); ok {
   158  				return ce.ValidateName("root")
   159  			}
   160  			return err
   161  		}
   162  	}
   163  
   164  	return nil
   165  }
   166  
   167  func (m *TUFV001Schema) contextValidateSpecVersion(ctx context.Context, formats strfmt.Registry) error {
   168  
   169  	if err := validate.ReadOnly(ctx, "spec_version", "body", string(m.SpecVersion)); err != nil {
   170  		return err
   171  	}
   172  
   173  	return nil
   174  }
   175  
   176  // MarshalBinary interface implementation
   177  func (m *TUFV001Schema) MarshalBinary() ([]byte, error) {
   178  	if m == nil {
   179  		return nil, nil
   180  	}
   181  	return swag.WriteJSON(m)
   182  }
   183  
   184  // UnmarshalBinary interface implementation
   185  func (m *TUFV001Schema) UnmarshalBinary(b []byte) error {
   186  	var res TUFV001Schema
   187  	if err := swag.ReadJSON(b, &res); err != nil {
   188  		return err
   189  	}
   190  	*m = res
   191  	return nil
   192  }
   193  
   194  // TUFV001SchemaMetadata TUF metadata
   195  //
   196  // swagger:model TUFV001SchemaMetadata
   197  type TUFV001SchemaMetadata struct {
   198  
   199  	// Specifies the metadata inline within the document
   200  	// Required: true
   201  	Content interface{} `json:"content"`
   202  }
   203  
   204  // Validate validates this TUF v001 schema metadata
   205  func (m *TUFV001SchemaMetadata) Validate(formats strfmt.Registry) error {
   206  	var res []error
   207  
   208  	if err := m.validateContent(formats); err != nil {
   209  		res = append(res, err)
   210  	}
   211  
   212  	if len(res) > 0 {
   213  		return errors.CompositeValidationError(res...)
   214  	}
   215  	return nil
   216  }
   217  
   218  func (m *TUFV001SchemaMetadata) validateContent(formats strfmt.Registry) error {
   219  
   220  	if m.Content == nil {
   221  		return errors.Required("metadata"+"."+"content", "body", nil)
   222  	}
   223  
   224  	return nil
   225  }
   226  
   227  // ContextValidate validates this TUF v001 schema metadata based on context it is used
   228  func (m *TUFV001SchemaMetadata) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   229  	return nil
   230  }
   231  
   232  // MarshalBinary interface implementation
   233  func (m *TUFV001SchemaMetadata) MarshalBinary() ([]byte, error) {
   234  	if m == nil {
   235  		return nil, nil
   236  	}
   237  	return swag.WriteJSON(m)
   238  }
   239  
   240  // UnmarshalBinary interface implementation
   241  func (m *TUFV001SchemaMetadata) UnmarshalBinary(b []byte) error {
   242  	var res TUFV001SchemaMetadata
   243  	if err := swag.ReadJSON(b, &res); err != nil {
   244  		return err
   245  	}
   246  	*m = res
   247  	return nil
   248  }
   249  
   250  // TUFV001SchemaRoot root metadata containing about the public keys used to sign the manifest
   251  //
   252  // swagger:model TUFV001SchemaRoot
   253  type TUFV001SchemaRoot struct {
   254  
   255  	// Specifies the metadata inline within the document
   256  	// Required: true
   257  	Content interface{} `json:"content"`
   258  }
   259  
   260  // Validate validates this TUF v001 schema root
   261  func (m *TUFV001SchemaRoot) Validate(formats strfmt.Registry) error {
   262  	var res []error
   263  
   264  	if err := m.validateContent(formats); err != nil {
   265  		res = append(res, err)
   266  	}
   267  
   268  	if len(res) > 0 {
   269  		return errors.CompositeValidationError(res...)
   270  	}
   271  	return nil
   272  }
   273  
   274  func (m *TUFV001SchemaRoot) validateContent(formats strfmt.Registry) error {
   275  
   276  	if m.Content == nil {
   277  		return errors.Required("root"+"."+"content", "body", nil)
   278  	}
   279  
   280  	return nil
   281  }
   282  
   283  // ContextValidate validates this TUF v001 schema root based on context it is used
   284  func (m *TUFV001SchemaRoot) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   285  	return nil
   286  }
   287  
   288  // MarshalBinary interface implementation
   289  func (m *TUFV001SchemaRoot) MarshalBinary() ([]byte, error) {
   290  	if m == nil {
   291  		return nil, nil
   292  	}
   293  	return swag.WriteJSON(m)
   294  }
   295  
   296  // UnmarshalBinary interface implementation
   297  func (m *TUFV001SchemaRoot) UnmarshalBinary(b []byte) error {
   298  	var res TUFV001SchemaRoot
   299  	if err := swag.ReadJSON(b, &res); err != nil {
   300  		return err
   301  	}
   302  	*m = res
   303  	return nil
   304  }
   305  

View as plain text