apiserver: k8s.io/apiserver/pkg/endpoints/handlers/negotiation Index | Files

package negotiation

import "k8s.io/apiserver/pkg/endpoints/handlers/negotiation"

Package negotiation contains media type negotiation logic.

Index

Package Files

doc.go errors.go negotiate.go

Variables

var DefaultEndpointRestrictions = emptyEndpointRestrictions{}

DefaultEndpointRestrictions is the default EndpointRestrictions which allows content-type negotiation to verify server support for specific options

func MediaTypesForSerializer Uses

func MediaTypesForSerializer(ns runtime.NegotiatedSerializer) (mediaTypes, streamMediaTypes []string)

MediaTypesForSerializer returns a list of media and stream media types for the server.

func NegotiateInputSerializer Uses

func NegotiateInputSerializer(req *http.Request, streaming bool, ns runtime.NegotiatedSerializer) (runtime.SerializerInfo, error)

NegotiateInputSerializer returns the input serializer for the provided request.

func NegotiateInputSerializerForMediaType Uses

func NegotiateInputSerializerForMediaType(mediaType string, streaming bool, ns runtime.NegotiatedSerializer) (runtime.SerializerInfo, error)

NegotiateInputSerializerForMediaType returns the appropriate serializer for the given media type or an error.

func NegotiateOutputMediaTypeStream Uses

func NegotiateOutputMediaTypeStream(req *http.Request, ns runtime.NegotiatedSerializer, restrictions EndpointRestrictions) (runtime.SerializerInfo, error)

NegotiateOutputMediaTypeStream returns a stream serializer for the given request.

func NewNotAcceptableConversionError Uses

func NewNotAcceptableConversionError(target string, accepted []string) error

NewNotAcceptableConversionError returns an error indicating that the desired API transformation to the target group version kind string is not accepted and only the listed mime types are allowed. This is temporary while Table does not yet support protobuf encoding.

func NewNotAcceptableError Uses

func NewNotAcceptableError(accepted []string) error

NewNotAcceptableError returns an error of NotAcceptable which contains specified string

func NewUnsupportedMediaTypeError Uses

func NewUnsupportedMediaTypeError(accepted []string) error

NewUnsupportedMediaTypeError returns an error of UnsupportedMediaType which contains specified string

type EndpointRestrictions Uses

type EndpointRestrictions interface {
    // AllowsMediaTypeTransform returns true if the endpoint allows either the requested mime type
    // or the requested transformation. If false, the caller should ignore this mime type. If the
    // target is nil, the client is not requesting a transformation.
    AllowsMediaTypeTransform(mimeType, mimeSubType string, target *schema.GroupVersionKind) bool
    // AllowsServerVersion should return true if the specified version is valid
    // for the server group.
    AllowsServerVersion(version string) bool
    // AllowsStreamSchema should return true if the specified stream schema is
    // valid for the server group.
    AllowsStreamSchema(schema string) bool
}

EndpointRestrictions is an interface that allows content-type negotiation to verify server support for specific options

type MediaTypeOptions Uses

type MediaTypeOptions struct {
    // pretty is true if the requested representation should be formatted for human
    // viewing
    Pretty bool

    // stream, if set, indicates that a streaming protocol variant of this encoding
    // is desired. The only currently supported value is watch which returns versioned
    // events. In the future, this may refer to other stream protocols.
    Stream string

    // convert is a request to alter the type of object returned by the server from the
    // normal response
    Convert *schema.GroupVersionKind
    // useServerVersion is an optional version for the server group
    UseServerVersion string

    // export is true if the representation requested should exclude fields the server
    // has set
    Export bool

    // unrecognized is a list of all unrecognized keys
    Unrecognized []string

    // the accepted media type from the client
    Accepted runtime.SerializerInfo
}

MediaTypeOptions describes information for a given media type that may alter the server response

func NegotiateMediaTypeOptions Uses

func NegotiateMediaTypeOptions(header string, accepted []runtime.SerializerInfo, endpoint EndpointRestrictions) (MediaTypeOptions, bool)

NegotiateMediaTypeOptions returns the most appropriate content type given the accept header and a list of alternatives along with the accepted media type parameters.

func NegotiateOutputMediaType Uses

func NegotiateOutputMediaType(req *http.Request, ns runtime.NegotiatedSerializer, restrictions EndpointRestrictions) (MediaTypeOptions, runtime.SerializerInfo, error)

NegotiateOutputMediaType negotiates the output structured media type and a serializer, or returns an error.

Package negotiation imports 9 packages (graph) and is imported by 12 packages. Updated 2019-12-14. Refresh now. Tools for package owners.