2014-07-29 21:35:46 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package apiserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RESTStorage is a generic interface for RESTful storage services
|
|
|
|
// Resources which are exported to the RESTful API of apiserver need to implement this interface.
|
|
|
|
type RESTStorage interface {
|
2014-08-06 03:10:48 +00:00
|
|
|
// New returns an empty object that can be used with Create and Update after request data has been put into it.
|
|
|
|
// This object must be a pointer type for use with Codec.DecodeInto([]byte, interface{})
|
|
|
|
New() interface{}
|
|
|
|
|
2014-07-29 21:35:46 +00:00
|
|
|
// List selects resources in the storage which match to the selector.
|
2014-08-05 20:33:25 +00:00
|
|
|
// TODO: add field selector in addition to label selector.
|
2014-07-29 21:35:46 +00:00
|
|
|
List(labels.Selector) (interface{}, error)
|
|
|
|
|
|
|
|
// Get finds a resource in the storage by id and returns it.
|
|
|
|
// Although it can return an arbitrary error value, IsNotFound(err) is true for the returned error value err when the specified resource is not found.
|
|
|
|
Get(id string) (interface{}, error)
|
|
|
|
|
|
|
|
// Delete finds a resource in the storage and deletes it.
|
|
|
|
// Although it can return an arbitrary error value, IsNotFound(err) is true for the returned error value err when the specified resource is not found.
|
|
|
|
Delete(id string) (<-chan interface{}, error)
|
|
|
|
|
|
|
|
Create(interface{}) (<-chan interface{}, error)
|
|
|
|
Update(interface{}) (<-chan interface{}, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResourceWatcher should be implemented by all RESTStorage objects that
|
|
|
|
// want to offer the ability to watch for changes through the watch api.
|
|
|
|
type ResourceWatcher interface {
|
2014-08-05 20:33:25 +00:00
|
|
|
// label selects on labels; field selects on the objects fields. Not all fields
|
|
|
|
// are supported; an error will be returned if you try to select for a field that
|
|
|
|
// isn't supported.
|
|
|
|
WatchAll(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
|
|
|
|
// TODO: Decide if we need to keep WatchSingle?
|
|
|
|
WatchSingle(id string, resourceVersion uint64) (watch.Interface, error)
|
2014-07-29 21:35:46 +00:00
|
|
|
}
|