{"modulePath":"github.com/dockerstack/kubernetes","version":"v0.20.1-0.20150627061651-1c0b765df6da","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package rest\n\nPackage rest defines common logic around changes to Kubernetes resources.\n\n## Variables\n\n```go\nvar Services = svcStrategy{api.Scheme, api.SimpleNameGenerator}\n```\nServices is the default logic that applies when creating and updating Service objects.\n\n## Functions\n\n```go\nfunc BeforeCreate(strategy RESTCreateStrategy, ctx api.Context, obj runtime.Object) error\n```\nBeforeCreate ensures that common operations for all resources are performed on creation. It only returns errors that can be converted to api.Status. It invokes PrepareForCreate, then GenerateName, then Validate. It returns nil if the object should be created.\n\n```go\nfunc BeforeDelete(strategy RESTDeleteStrategy, ctx api.Context, obj runtime.Object, options *api.DeleteOptions) (graceful, gracefulPending bool, err error)\n```\nBeforeDelete tests whether the object can be gracefully deleted. If graceful is set the object should be gracefully deleted, if gracefulPending is set the object has already been gracefully deleted (and the provided grace period is longer than the time to deletion), and an error is returned if the condition cannot be checked or the gracePeriodSeconds is invalid. The options argument may be updated with default values if graceful is true.\n\n```go\nfunc BeforeUpdate(strategy RESTUpdateStrategy, ctx api.Context, obj, old runtime.Object) error\n```\nBeforeUpdate ensures that common operations for all resources are performed on update. It only returns errors that can be converted to api.Status. It will invoke update validation with the provided existing and updated objects.\n\n```go\nfunc CheckGeneratedNameError(strategy RESTCreateStrategy, err error, obj runtime.Object) error\n```\nCheckGeneratedNameError checks whether an error that occurred creating a resource is due to generation being unable to pick a valid name.\n\n## Types\n\n```go\ntype ConnectHandler interface {\n\thttp.Handler\n\n\t// RequestError returns an error if one occurred during handling of an HTTP request\n\tRequestError() error\n}\n```\nConnectHandler is a handler for HTTP connection requests. It extends the standard http.Handler interface by adding a method that returns an error object if an error occurred during the handling of the request.\n\n```go\ntype ConnectRequest struct {\n\t// Name is the name of the object on which the connect request was made\n\tName string\n\n\t// Options is the options object passed to the connect request. See the NewConnectOptions method on Connecter\n\tOptions runtime.Object\n\n\t// ResourcePath is the path for the resource in the REST server (ie. \"pods/proxy\")\n\tResourcePath string\n}\n```\nConnectRequest is an object passed to admission control for Connect operations\n\n```go\nfunc (*ConnectRequest) IsAnAPIObject()\n```\nIsAnAPIObject makes ConnectRequest a runtime.Object\n\n```go\ntype Connecter interface {\n\t// Connect returns a ConnectHandler that will handle the request/response for a request\n\tConnect(ctx api.Context, id string, options runtime.Object) (ConnectHandler, error)\n\n\t// NewConnectOptions returns an empty options object that will be used to pass\n\t// options to the Connect method. If nil, then a nil options object is passed to\n\t// Connect. It may return a bool and a string. If true, the value of the request\n\t// path below the object will be included as the named string in the serialization\n\t// of the runtime object.\n\tNewConnectOptions() (runtime.Object, bool, string)\n\n\t// ConnectMethods returns the list of HTTP methods handled by Connect\n\tConnectMethods() []string\n}\n```\nConnecter is a storage object that responds to a connection request\n\n```go\ntype Creater interface {\n\t// New returns an empty object that can be used with Create after request data has been put into it.\n\t// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)\n\tNew() runtime.Object\n\n\t// Create creates a new version of a resource.\n\tCreate(ctx api.Context, obj runtime.Object) (runtime.Object, error)\n}\n```\nCreater is an object that can create an instance of a RESTful object.\n\n```go\ntype CreaterUpdater interface {\n\tCreater\n\tUpdate(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error)\n}\n```\nCreaterUpdater is a storage object that must support both create and update. Go prevents embedded interfaces that implement the same method.\n\n```go\ntype Deleter interface {\n\t// Delete finds a resource in the storage and deletes it.\n\t// Although it can return an arbitrary error value, IsNotFound(err) is true for the\n\t// returned error value err when the specified resource is not found.\n\t// Delete *may* return the object that was deleted, or a status object indicating additional\n\t// information about deletion.\n\tDelete(ctx api.Context, name string) (runtime.Object, error)\n}\n```\nDeleter is an object that can delete a named RESTful resource.\n\n```go\ntype Getter interface {\n\t// Get finds a resource in the storage by name and returns it.\n\t// Although it can return an arbitrary error value, IsNotFound(err) is true for the\n\t// returned error value err when the specified resource is not found.\n\tGet(ctx api.Context, name string) (runtime.Object, error)\n}\n```\nGetter is an object that can retrieve a named RESTful resource.\n\n```go\ntype GetterWithOptions interface {\n\t// Get finds a resource in the storage by name and returns it.\n\t// Although it can return an arbitrary error value, IsNotFound(err) is true for the\n\t// returned error value err when the specified resource is not found.\n\t// The options object passed to it is of the same type returned by the NewGetOptions\n\t// method.\n\tGet(ctx api.Context, name string, options runtime.Object) (runtime.Object, error)\n\n\t// NewGetOptions returns an empty options object that will be used to pass\n\t// options to the Get method. It may return a bool and a string, if true, the\n\t// value of the request path below the object will be included as the named\n\t// string in the serialization of the runtime object. E.g., returning \"path\"\n\t// will convert the trailing request scheme value to \"path\" in the map[string][]string\n\t// passed to the convertor.\n\tNewGetOptions() (runtime.Object, bool, string)\n}\n```\nGetterWithOptions is an object that retrieve a named RESTful resource and takes additional options on the get request. It allows a caller to also receive the subpath of the GET request.\n\n```go\ntype GracefulDeleteAdapter struct {\n\tDeleter\n}\n```\nGracefulDeleteAdapter adapts the Deleter interface to GracefulDeleter\n\n```go\nfunc (w GracefulDeleteAdapter) Delete(ctx api.Context, name string, options *api.DeleteOptions) (runtime.Object, error)\n```\nDelete implements RESTGracefulDeleter in terms of Deleter\n\n```go\ntype GracefulDeleter interface {\n\t// Delete finds a resource in the storage and deletes it.\n\t// If options are provided, the resource will attempt to honor them or return an invalid\n\t// request error.\n\t// Although it can return an arbitrary error value, IsNotFound(err) is true for the\n\t// returned error value err when the specified resource is not found.\n\t// Delete *may* return the object that was deleted, or a status object indicating additional\n\t// information about deletion.\n\tDelete(ctx api.Context, name string, options *api.DeleteOptions) (runtime.Object, error)\n}\n```\nGracefulDeleter knows how to pass deletion options to allow delayed deletion of a RESTful object.\n\n```go\ntype Lister interface {\n\t// NewList returns an empty object that can be used with the List call.\n\t// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)\n\tNewList() runtime.Object\n\t// List selects resources in the storage which match to the selector.\n\tList(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error)\n}\n```\nLister is an object that can retrieve resources that match the provided field and label criteria.\n\n```go\ntype NamedCreater interface {\n\t// New returns an empty object that can be used with Create after request data has been put into it.\n\t// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)\n\tNew() runtime.Object\n\n\t// Create creates a new version of a resource. It expects a name parameter from the path.\n\t// This is needed for create operations on subresources which include the name of the parent\n\t// resource in the path.\n\tCreate(ctx api.Context, name string, obj runtime.Object) (runtime.Object, error)\n}\n```\nNamedCreater is an object that can create an instance of a RESTful object using a name parameter.\n\n```go\ntype ObjectFunc func(obj runtime.Object) error\n```\nObjectFunc is a function to act on a given object. An error may be returned if the hook cannot be completed. An ObjectFunc may transform the provided object.\n\n```go\nfunc AllFuncs(fns ...ObjectFunc) ObjectFunc\n```\nAllFuncs returns an ObjectFunc that attempts to run all of the provided functions in order, returning early if there are any errors.\n\n```go\ntype Patcher interface {\n\tGetter\n\tUpdater\n}\n```\nPatcher is a storage object that supports both get and update.\n\n```go\ntype RESTCreateStrategy interface {\n\truntime.ObjectTyper\n\t// The name generate is used when the standard GenerateName field is set.\n\t// The NameGenerator will be invoked prior to validation.\n\tapi.NameGenerator\n\n\t// NamespaceScoped returns true if the object must be within a namespace.\n\tNamespaceScoped() bool\n\t// PrepareForCreate is invoked on create before validation to normalize\n\t// the object.  For example: remove fields that are not to be persisted,\n\t// sort order-insensitive list fields, etc.\n\tPrepareForCreate(obj runtime.Object)\n\t// Validate is invoked after default fields in the object have been filled in before\n\t// the object is persisted.\n\tValidate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList\n}\n```\nRESTCreateStrategy defines the minimum validation, accepted input, and name generation behavior to create an object that follows Kubernetes API conventions.\n\n```go\ntype RESTDeleteStrategy interface {\n\truntime.ObjectTyper\n\n\t// CheckGracefulDelete should return true if the object can be gracefully deleted and set\n\t// any default values on the DeleteOptions.\n\tCheckGracefulDelete(obj runtime.Object, options *api.DeleteOptions) bool\n}\n```\nRESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes API conventions.\n\n```go\ntype RESTUpdateStrategy interface {\n\truntime.ObjectTyper\n\t// NamespaceScoped returns true if the object must be within a namespace.\n\tNamespaceScoped() bool\n\t// AllowCreateOnUpdate returns true if the object can be created by a PUT.\n\tAllowCreateOnUpdate() bool\n\t// PrepareForUpdate is invoked on update before validation to normalize\n\t// the object.  For example: remove fields that are not to be persisted,\n\t// sort order-insensitive list fields, etc.\n\tPrepareForUpdate(obj, old runtime.Object)\n\t// ValidateUpdate is invoked after default fields in the object have been filled in before\n\t// the object is persisted.\n\tValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList\n\t// AllowUnconditionalUpdate returns true if the object can be updated unconditionally (irrespective of the latest resource version), when there is no resource version specified in the object.\n\tAllowUnconditionalUpdate() bool\n}\n```\nRESTUpdateStrategy defines the minimum validation, accepted input, and name generation behavior to update an object that follows Kubernetes API conventions. A resource may have many UpdateStrategies, depending on the call pattern in use.\n\n```go\ntype Redirector interface {\n\t// ResourceLocation should return the remote location of the given resource, and an optional transport to use to request it, or an error.\n\tResourceLocation(ctx api.Context, id string) (remoteLocation *url.URL, transport http.RoundTripper, err error)\n}\n```\nRedirector know how to return a remote resource's location.\n\n```go\ntype ResourceStreamer interface {\n\t// InputStream should return an io.ReadCloser if the provided object supports streaming. The desired\n\t// api version and a accept header (may be empty) are passed to the call. If no error occurs,\n\t// the caller may return a flag indicating whether the result should be flushed as writes occur\n\t// and a content type string that indicates the type of the stream.\n\t// If a null stream is returned, a StatusNoContent response wil be generated.\n\tInputStream(apiVersion, acceptHeader string) (stream io.ReadCloser, flush bool, mimeType string, err error)\n}\n```\nResourceStreamer is an interface implemented by objects that prefer to be streamed from the server instead of decoded directly.\n\n```go\ntype StandardStorage interface {\n\tGetter\n\tLister\n\tCreaterUpdater\n\tGracefulDeleter\n\tWatcher\n}\n```\nStandardStorage is an interface covering the common verbs. Provided for testing whether a resource satisfies the normal storage methods. Use Storage when passing opaque storage objects.\n\n```go\ntype Storage interface {\n\t// New returns an empty object that can be used with Create and Update after request data has been put into it.\n\t// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)\n\tNew() runtime.Object\n}\n```\nStorage is a generic interface for RESTful storage services. Resources which are exported to the RESTful API of apiserver need to implement this interface. It is expected that objects may implement any of the below interfaces.\n\n```go\ntype StorageMetadata interface {\n\t// ProducesMIMETypes returns a list of the MIME types the specified HTTP verb (GET, POST, DELETE,\n\t// PATCH) can respond with.\n\tProducesMIMETypes(verb string) []string\n}\n```\nStorageMetadata is an optional interface that callers can implement to provide additional information about their Storage objects.\n\n```go\ntype Updater interface {\n\t// New returns an empty object that can be used with Update after request data has been put into it.\n\t// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)\n\tNew() runtime.Object\n\n\t// Update finds a resource in the storage and updates it. Some implementations\n\t// may allow updates creates the object - they should set the created boolean\n\t// to true.\n\tUpdate(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error)\n}\n```\nUpdater is an object that can update an instance of a RESTful object.\n\n```go\ntype Watcher interface {\n\t// 'label' selects on labels; 'field' selects on the object's fields. Not all fields\n\t// are supported; an error should be returned if 'field' tries to select on a field that\n\t// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a\n\t// particular version.\n\tWatch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)\n}\n```\nWatcher should be implemented by all Storage objects that want to offer the ability to watch for changes through the watch api.\n\n","path":"github.com/dockerstack/kubernetes/pkg/api/rest","name":"rest","synopsis":"Package rest defines common logic around changes to Kubernetes resources.","isRedistributable":true}
