...

Source file src/github.com/sigstore/rekor/pkg/generated/models/log_entry.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  // LogEntry log entry
    34  //
    35  // swagger:model LogEntry
    36  type LogEntry map[string]LogEntryAnon
    37  
    38  // Validate validates this log entry
    39  func (m LogEntry) Validate(formats strfmt.Registry) error {
    40  	var res []error
    41  
    42  	for k := range m {
    43  
    44  		if swag.IsZero(m[k]) { // not required
    45  			continue
    46  		}
    47  		if val, ok := m[k]; ok {
    48  			if err := val.Validate(formats); err != nil {
    49  				if ve, ok := err.(*errors.Validation); ok {
    50  					return ve.ValidateName(k)
    51  				} else if ce, ok := err.(*errors.CompositeError); ok {
    52  					return ce.ValidateName(k)
    53  				}
    54  				return err
    55  			}
    56  		}
    57  
    58  	}
    59  
    60  	if len(res) > 0 {
    61  		return errors.CompositeValidationError(res...)
    62  	}
    63  	return nil
    64  }
    65  
    66  // ContextValidate validate this log entry based on the context it is used
    67  func (m LogEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    68  	var res []error
    69  
    70  	for k := range m {
    71  
    72  		if val, ok := m[k]; ok {
    73  			if err := val.ContextValidate(ctx, formats); err != nil {
    74  				return err
    75  			}
    76  		}
    77  
    78  	}
    79  
    80  	if len(res) > 0 {
    81  		return errors.CompositeValidationError(res...)
    82  	}
    83  	return nil
    84  }
    85  
    86  // LogEntryAnon log entry anon
    87  //
    88  // swagger:model LogEntryAnon
    89  type LogEntryAnon struct {
    90  
    91  	// attestation
    92  	Attestation *LogEntryAnonAttestation `json:"attestation,omitempty"`
    93  
    94  	// body
    95  	// Required: true
    96  	Body interface{} `json:"body"`
    97  
    98  	// The time the entry was added to the log as a Unix timestamp in seconds
    99  	// Required: true
   100  	IntegratedTime *int64 `json:"integratedTime"`
   101  
   102  	// This is the SHA256 hash of the DER-encoded public key for the log at the time the entry was included in the log
   103  	// Required: true
   104  	// Pattern: ^[0-9a-fA-F]{64}$
   105  	LogID *string `json:"logID"`
   106  
   107  	// log index
   108  	// Required: true
   109  	// Minimum: 0
   110  	LogIndex *int64 `json:"logIndex"`
   111  
   112  	// verification
   113  	Verification *LogEntryAnonVerification `json:"verification,omitempty"`
   114  }
   115  
   116  // Validate validates this log entry anon
   117  func (m *LogEntryAnon) Validate(formats strfmt.Registry) error {
   118  	var res []error
   119  
   120  	if err := m.validateAttestation(formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if err := m.validateBody(formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if err := m.validateIntegratedTime(formats); err != nil {
   129  		res = append(res, err)
   130  	}
   131  
   132  	if err := m.validateLogID(formats); err != nil {
   133  		res = append(res, err)
   134  	}
   135  
   136  	if err := m.validateLogIndex(formats); err != nil {
   137  		res = append(res, err)
   138  	}
   139  
   140  	if err := m.validateVerification(formats); err != nil {
   141  		res = append(res, err)
   142  	}
   143  
   144  	if len(res) > 0 {
   145  		return errors.CompositeValidationError(res...)
   146  	}
   147  	return nil
   148  }
   149  
   150  func (m *LogEntryAnon) validateAttestation(formats strfmt.Registry) error {
   151  	if swag.IsZero(m.Attestation) { // not required
   152  		return nil
   153  	}
   154  
   155  	if m.Attestation != nil {
   156  		if err := m.Attestation.Validate(formats); err != nil {
   157  			if ve, ok := err.(*errors.Validation); ok {
   158  				return ve.ValidateName("attestation")
   159  			} else if ce, ok := err.(*errors.CompositeError); ok {
   160  				return ce.ValidateName("attestation")
   161  			}
   162  			return err
   163  		}
   164  	}
   165  
   166  	return nil
   167  }
   168  
   169  func (m *LogEntryAnon) validateBody(formats strfmt.Registry) error {
   170  
   171  	if m.Body == nil {
   172  		return errors.Required("body", "body", nil)
   173  	}
   174  
   175  	return nil
   176  }
   177  
   178  func (m *LogEntryAnon) validateIntegratedTime(formats strfmt.Registry) error {
   179  
   180  	if err := validate.Required("integratedTime", "body", m.IntegratedTime); err != nil {
   181  		return err
   182  	}
   183  
   184  	return nil
   185  }
   186  
   187  func (m *LogEntryAnon) validateLogID(formats strfmt.Registry) error {
   188  
   189  	if err := validate.Required("logID", "body", m.LogID); err != nil {
   190  		return err
   191  	}
   192  
   193  	if err := validate.Pattern("logID", "body", *m.LogID, `^[0-9a-fA-F]{64}$`); err != nil {
   194  		return err
   195  	}
   196  
   197  	return nil
   198  }
   199  
   200  func (m *LogEntryAnon) validateLogIndex(formats strfmt.Registry) error {
   201  
   202  	if err := validate.Required("logIndex", "body", m.LogIndex); err != nil {
   203  		return err
   204  	}
   205  
   206  	if err := validate.MinimumInt("logIndex", "body", *m.LogIndex, 0, false); err != nil {
   207  		return err
   208  	}
   209  
   210  	return nil
   211  }
   212  
   213  func (m *LogEntryAnon) validateVerification(formats strfmt.Registry) error {
   214  	if swag.IsZero(m.Verification) { // not required
   215  		return nil
   216  	}
   217  
   218  	if m.Verification != nil {
   219  		if err := m.Verification.Validate(formats); err != nil {
   220  			if ve, ok := err.(*errors.Validation); ok {
   221  				return ve.ValidateName("verification")
   222  			} else if ce, ok := err.(*errors.CompositeError); ok {
   223  				return ce.ValidateName("verification")
   224  			}
   225  			return err
   226  		}
   227  	}
   228  
   229  	return nil
   230  }
   231  
   232  // ContextValidate validate this log entry anon based on the context it is used
   233  func (m *LogEntryAnon) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   234  	var res []error
   235  
   236  	if err := m.contextValidateAttestation(ctx, formats); err != nil {
   237  		res = append(res, err)
   238  	}
   239  
   240  	if err := m.contextValidateVerification(ctx, formats); err != nil {
   241  		res = append(res, err)
   242  	}
   243  
   244  	if len(res) > 0 {
   245  		return errors.CompositeValidationError(res...)
   246  	}
   247  	return nil
   248  }
   249  
   250  func (m *LogEntryAnon) contextValidateAttestation(ctx context.Context, formats strfmt.Registry) error {
   251  
   252  	if m.Attestation != nil {
   253  
   254  		if swag.IsZero(m.Attestation) { // not required
   255  			return nil
   256  		}
   257  
   258  		if err := m.Attestation.ContextValidate(ctx, formats); err != nil {
   259  			if ve, ok := err.(*errors.Validation); ok {
   260  				return ve.ValidateName("attestation")
   261  			} else if ce, ok := err.(*errors.CompositeError); ok {
   262  				return ce.ValidateName("attestation")
   263  			}
   264  			return err
   265  		}
   266  	}
   267  
   268  	return nil
   269  }
   270  
   271  func (m *LogEntryAnon) contextValidateVerification(ctx context.Context, formats strfmt.Registry) error {
   272  
   273  	if m.Verification != nil {
   274  
   275  		if swag.IsZero(m.Verification) { // not required
   276  			return nil
   277  		}
   278  
   279  		if err := m.Verification.ContextValidate(ctx, formats); err != nil {
   280  			if ve, ok := err.(*errors.Validation); ok {
   281  				return ve.ValidateName("verification")
   282  			} else if ce, ok := err.(*errors.CompositeError); ok {
   283  				return ce.ValidateName("verification")
   284  			}
   285  			return err
   286  		}
   287  	}
   288  
   289  	return nil
   290  }
   291  
   292  // MarshalBinary interface implementation
   293  func (m *LogEntryAnon) MarshalBinary() ([]byte, error) {
   294  	if m == nil {
   295  		return nil, nil
   296  	}
   297  	return swag.WriteJSON(m)
   298  }
   299  
   300  // UnmarshalBinary interface implementation
   301  func (m *LogEntryAnon) UnmarshalBinary(b []byte) error {
   302  	var res LogEntryAnon
   303  	if err := swag.ReadJSON(b, &res); err != nil {
   304  		return err
   305  	}
   306  	*m = res
   307  	return nil
   308  }
   309  
   310  // LogEntryAnonAttestation log entry anon attestation
   311  //
   312  // swagger:model LogEntryAnonAttestation
   313  type LogEntryAnonAttestation struct {
   314  
   315  	// data
   316  	// Format: byte
   317  	Data strfmt.Base64 `json:"data,omitempty"`
   318  }
   319  
   320  // Validate validates this log entry anon attestation
   321  func (m *LogEntryAnonAttestation) Validate(formats strfmt.Registry) error {
   322  	return nil
   323  }
   324  
   325  // ContextValidate validates this log entry anon attestation based on context it is used
   326  func (m *LogEntryAnonAttestation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   327  	return nil
   328  }
   329  
   330  // MarshalBinary interface implementation
   331  func (m *LogEntryAnonAttestation) MarshalBinary() ([]byte, error) {
   332  	if m == nil {
   333  		return nil, nil
   334  	}
   335  	return swag.WriteJSON(m)
   336  }
   337  
   338  // UnmarshalBinary interface implementation
   339  func (m *LogEntryAnonAttestation) UnmarshalBinary(b []byte) error {
   340  	var res LogEntryAnonAttestation
   341  	if err := swag.ReadJSON(b, &res); err != nil {
   342  		return err
   343  	}
   344  	*m = res
   345  	return nil
   346  }
   347  
   348  // LogEntryAnonVerification log entry anon verification
   349  //
   350  // swagger:model LogEntryAnonVerification
   351  type LogEntryAnonVerification struct {
   352  
   353  	// inclusion proof
   354  	InclusionProof *InclusionProof `json:"inclusionProof,omitempty"`
   355  
   356  	// Signature over the logID, logIndex, body and integratedTime.
   357  	// Format: byte
   358  	SignedEntryTimestamp strfmt.Base64 `json:"signedEntryTimestamp,omitempty"`
   359  }
   360  
   361  // Validate validates this log entry anon verification
   362  func (m *LogEntryAnonVerification) Validate(formats strfmt.Registry) error {
   363  	var res []error
   364  
   365  	if err := m.validateInclusionProof(formats); err != nil {
   366  		res = append(res, err)
   367  	}
   368  
   369  	if len(res) > 0 {
   370  		return errors.CompositeValidationError(res...)
   371  	}
   372  	return nil
   373  }
   374  
   375  func (m *LogEntryAnonVerification) validateInclusionProof(formats strfmt.Registry) error {
   376  	if swag.IsZero(m.InclusionProof) { // not required
   377  		return nil
   378  	}
   379  
   380  	if m.InclusionProof != nil {
   381  		if err := m.InclusionProof.Validate(formats); err != nil {
   382  			if ve, ok := err.(*errors.Validation); ok {
   383  				return ve.ValidateName("verification" + "." + "inclusionProof")
   384  			} else if ce, ok := err.(*errors.CompositeError); ok {
   385  				return ce.ValidateName("verification" + "." + "inclusionProof")
   386  			}
   387  			return err
   388  		}
   389  	}
   390  
   391  	return nil
   392  }
   393  
   394  // ContextValidate validate this log entry anon verification based on the context it is used
   395  func (m *LogEntryAnonVerification) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   396  	var res []error
   397  
   398  	if err := m.contextValidateInclusionProof(ctx, formats); err != nil {
   399  		res = append(res, err)
   400  	}
   401  
   402  	if len(res) > 0 {
   403  		return errors.CompositeValidationError(res...)
   404  	}
   405  	return nil
   406  }
   407  
   408  func (m *LogEntryAnonVerification) contextValidateInclusionProof(ctx context.Context, formats strfmt.Registry) error {
   409  
   410  	if m.InclusionProof != nil {
   411  
   412  		if swag.IsZero(m.InclusionProof) { // not required
   413  			return nil
   414  		}
   415  
   416  		if err := m.InclusionProof.ContextValidate(ctx, formats); err != nil {
   417  			if ve, ok := err.(*errors.Validation); ok {
   418  				return ve.ValidateName("verification" + "." + "inclusionProof")
   419  			} else if ce, ok := err.(*errors.CompositeError); ok {
   420  				return ce.ValidateName("verification" + "." + "inclusionProof")
   421  			}
   422  			return err
   423  		}
   424  	}
   425  
   426  	return nil
   427  }
   428  
   429  // MarshalBinary interface implementation
   430  func (m *LogEntryAnonVerification) MarshalBinary() ([]byte, error) {
   431  	if m == nil {
   432  		return nil, nil
   433  	}
   434  	return swag.WriteJSON(m)
   435  }
   436  
   437  // UnmarshalBinary interface implementation
   438  func (m *LogEntryAnonVerification) UnmarshalBinary(b []byte) error {
   439  	var res LogEntryAnonVerification
   440  	if err := swag.ReadJSON(b, &res); err != nil {
   441  		return err
   442  	}
   443  	*m = res
   444  	return nil
   445  }
   446  

View as plain text