...

Source file src/github.com/sigstore/rekor/pkg/generated/models/proposed_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  	"bytes"
    26  	"context"
    27  	"encoding/json"
    28  	"io"
    29  
    30  	"github.com/go-openapi/errors"
    31  	"github.com/go-openapi/runtime"
    32  	"github.com/go-openapi/strfmt"
    33  	"github.com/go-openapi/validate"
    34  )
    35  
    36  // ProposedEntry proposed entry
    37  //
    38  // swagger:discriminator ProposedEntry kind
    39  type ProposedEntry interface {
    40  	runtime.Validatable
    41  	runtime.ContextValidatable
    42  
    43  	// kind
    44  	// Required: true
    45  	Kind() string
    46  	SetKind(string)
    47  
    48  	// AdditionalProperties in base type shoud be handled just like regular properties
    49  	// At this moment, the base type property is pushed down to the subtype
    50  }
    51  
    52  type proposedEntry struct {
    53  	kindField string
    54  }
    55  
    56  // Kind gets the kind of this polymorphic type
    57  func (m *proposedEntry) Kind() string {
    58  	return "ProposedEntry"
    59  }
    60  
    61  // SetKind sets the kind of this polymorphic type
    62  func (m *proposedEntry) SetKind(val string) {
    63  }
    64  
    65  // UnmarshalProposedEntrySlice unmarshals polymorphic slices of ProposedEntry
    66  func UnmarshalProposedEntrySlice(reader io.Reader, consumer runtime.Consumer) ([]ProposedEntry, error) {
    67  	var elements []json.RawMessage
    68  	if err := consumer.Consume(reader, &elements); err != nil {
    69  		return nil, err
    70  	}
    71  
    72  	var result []ProposedEntry
    73  	for _, element := range elements {
    74  		obj, err := unmarshalProposedEntry(element, consumer)
    75  		if err != nil {
    76  			return nil, err
    77  		}
    78  		result = append(result, obj)
    79  	}
    80  	return result, nil
    81  }
    82  
    83  // UnmarshalProposedEntry unmarshals polymorphic ProposedEntry
    84  func UnmarshalProposedEntry(reader io.Reader, consumer runtime.Consumer) (ProposedEntry, error) {
    85  	// we need to read this twice, so first into a buffer
    86  	data, err := io.ReadAll(reader)
    87  	if err != nil {
    88  		return nil, err
    89  	}
    90  	return unmarshalProposedEntry(data, consumer)
    91  }
    92  
    93  func unmarshalProposedEntry(data []byte, consumer runtime.Consumer) (ProposedEntry, error) {
    94  	buf := bytes.NewBuffer(data)
    95  	buf2 := bytes.NewBuffer(data)
    96  
    97  	// the first time this is read is to fetch the value of the kind property.
    98  	var getType struct {
    99  		Kind string `json:"kind"`
   100  	}
   101  	if err := consumer.Consume(buf, &getType); err != nil {
   102  		return nil, err
   103  	}
   104  
   105  	if err := validate.RequiredString("kind", "body", getType.Kind); err != nil {
   106  		return nil, err
   107  	}
   108  
   109  	// The value of kind is used to determine which type to create and unmarshal the data into
   110  	switch getType.Kind {
   111  	case "ProposedEntry":
   112  		var result proposedEntry
   113  		if err := consumer.Consume(buf2, &result); err != nil {
   114  			return nil, err
   115  		}
   116  		return &result, nil
   117  	case "alpine":
   118  		var result Alpine
   119  		if err := consumer.Consume(buf2, &result); err != nil {
   120  			return nil, err
   121  		}
   122  		return &result, nil
   123  	case "cose":
   124  		var result Cose
   125  		if err := consumer.Consume(buf2, &result); err != nil {
   126  			return nil, err
   127  		}
   128  		return &result, nil
   129  	case "dsse":
   130  		var result DSSE
   131  		if err := consumer.Consume(buf2, &result); err != nil {
   132  			return nil, err
   133  		}
   134  		return &result, nil
   135  	case "hashedrekord":
   136  		var result Hashedrekord
   137  		if err := consumer.Consume(buf2, &result); err != nil {
   138  			return nil, err
   139  		}
   140  		return &result, nil
   141  	case "helm":
   142  		var result Helm
   143  		if err := consumer.Consume(buf2, &result); err != nil {
   144  			return nil, err
   145  		}
   146  		return &result, nil
   147  	case "intoto":
   148  		var result Intoto
   149  		if err := consumer.Consume(buf2, &result); err != nil {
   150  			return nil, err
   151  		}
   152  		return &result, nil
   153  	case "jar":
   154  		var result Jar
   155  		if err := consumer.Consume(buf2, &result); err != nil {
   156  			return nil, err
   157  		}
   158  		return &result, nil
   159  	case "rekord":
   160  		var result Rekord
   161  		if err := consumer.Consume(buf2, &result); err != nil {
   162  			return nil, err
   163  		}
   164  		return &result, nil
   165  	case "rfc3161":
   166  		var result Rfc3161
   167  		if err := consumer.Consume(buf2, &result); err != nil {
   168  			return nil, err
   169  		}
   170  		return &result, nil
   171  	case "rpm":
   172  		var result Rpm
   173  		if err := consumer.Consume(buf2, &result); err != nil {
   174  			return nil, err
   175  		}
   176  		return &result, nil
   177  	case "tuf":
   178  		var result TUF
   179  		if err := consumer.Consume(buf2, &result); err != nil {
   180  			return nil, err
   181  		}
   182  		return &result, nil
   183  	}
   184  	return nil, errors.New(422, "invalid kind value: %q", getType.Kind)
   185  }
   186  
   187  // Validate validates this proposed entry
   188  func (m *proposedEntry) Validate(formats strfmt.Registry) error {
   189  	return nil
   190  }
   191  
   192  // ContextValidate validates this proposed entry based on context it is used
   193  func (m *proposedEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   194  	return nil
   195  }
   196  

View as plain text