From afedbba3fc17cc3ede9884e8ab1b7aa5d7da49d1 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 23 Dec 2014 16:14:32 -0500 Subject: [PATCH 1/2] Introduce Resource/ResourceName/Prefix/Suffix options to RESTClient RESTClient is an abstraction for simplifying access to resources that follow the Kubernetes API pattern. Currently, both Namespace and Path are coupled, which means changes across versions is complex. In general, most access to resources should be to a resource collection (e.g. "services") with a name (e.g. "foo"). Other constructs, like prefix sections ("watch") or proposed suffix sections ("/pods/foo/spec") only modify this core pattern. This commit removes the Path() helper from Request and introduces: * Prefix(segments ...string) - segments that should go to the beginning of the path. * Suffix(segments ...string) - segments that should go to the end of the path. * Resource(string) - collection name, should be after prefix * Namespace(string) - if specified, should be set after resource but before name * Name(string) - if specified, should be after namespace Now, only Prefix and Suffix are order dependent (and with variadics, should be simpler). Resource, Namespace, and Name may be specified in any order. Path() has been removed to prevent downstream consumers of RESTClient from experiencing behavior change. --- pkg/client/request.go | 116 ++++++++++++++++++++++++++++++++---------- 1 file changed, 89 insertions(+), 27 deletions(-) diff --git a/pkg/client/request.go b/pkg/client/request.go index 0a4698c92ee..44e202d3544 100644 --- a/pkg/client/request.go +++ b/pkg/client/request.go @@ -89,16 +89,22 @@ type Request struct { // whether to poll. poller PollFunc - // accessible via method setters - path string - params map[string]string - selector labels.Selector - sync bool - timeout time.Duration - // If true, put ns/ in path; if false, add "?namespace=" as a query parameter namespaceInPath bool + // generic components accessible via method setters + path string + subpath string + params map[string]string + + // structural elements of the request that are part of the Kubernetes API conventions + namespace string + resource string + resourceName string + selector labels.Selector + sync bool + timeout time.Duration + // output err error body io.Reader @@ -116,12 +122,50 @@ func NewRequest(client HTTPClient, verb string, baseURL *url.URL, codec runtime. } } -// Path appends an item to the request path. You must call Path at least once. -func (r *Request) Path(item string) *Request { +// Prefix adds segments to the relative beginning to the request path. These +// items will be placed before the optional Namespace, Resource, or Name sections. +// Setting AbsPath will clear any previously set Prefix segments +func (r *Request) Prefix(segments ...string) *Request { if r.err != nil { return r } - r.path = path.Join(r.path, item) + r.path = path.Join(r.path, path.Join(segments...)) + return r +} + +// Suffix appends segments to the end of the path. These items will be placed after the prefix and optional +// Namespace, Resource, or Name sections. +func (r *Request) Suffix(segments ...string) *Request { + if r.err != nil { + return r + } + r.subpath = path.Join(r.subpath, path.Join(segments...)) + return r +} + +// Resource sets the resource to access (/[ns//]) +func (r *Request) Resource(resource string) *Request { + if r.err != nil { + return r + } + if len(r.resource) != 0 { + r.err = fmt.Errorf("resource already set to %q, cannot change to %q", r.resource, resource) + return r + } + r.resource = resource + return r +} + +// Name sets the name of a resource to access (/[ns//]) +func (r *Request) Name(resourceName string) *Request { + if r.err != nil { + return r + } + if len(r.resourceName) != 0 { + r.err = fmt.Errorf("resource name already set to %q, cannot change to %q", r.resourceName, resourceName) + return r + } + r.resourceName = resourceName return r } @@ -134,29 +178,31 @@ func (r *Request) Sync(sync bool) *Request { return r } -// Namespace applies the namespace scope to a request +// Namespace applies the namespace scope to a request (/[ns//]) func (r *Request) Namespace(namespace string) *Request { if r.err != nil { return r } - - if len(namespace) > 0 { - if r.namespaceInPath { - return r.Path("ns").Path(namespace) - } else { - return r.setParam("namespace", namespace) - } - + if len(r.namespace) != 0 { + r.err = fmt.Errorf("namespace already set to %q, cannot change to %q", r.namespace, namespace) + return r } + r.namespace = namespace return r } -// AbsPath overwrites an existing path with the path parameter. -func (r *Request) AbsPath(path string) *Request { +// AbsPath overwrites an existing path with the segments provided. Trailing slashes are preserved +// when a single segment is passed. +func (r *Request) AbsPath(segments ...string) *Request { if r.err != nil { return r } - r.path = path + if len(segments) == 1 { + // preserve any trailing slashes for legacy behavior + r.path = segments[0] + } else { + r.path = path.Join(segments...) + } return r } @@ -273,13 +319,30 @@ func (r *Request) Poller(poller PollFunc) *Request { } func (r *Request) finalURL() string { + p := r.path + if r.namespaceInPath { + p = path.Join(p, "ns", r.namespace) + } + if len(r.resource) != 0 { + p = path.Join(p, r.resource) + } + // Join trims trailing slashes, so preserve r.path's trailing slash for backwards compat if nothing was changed + if len(r.resourceName) != 0 || len(r.subpath) != 0 { + p = path.Join(p, r.resourceName, r.subpath) + } + finalURL := *r.baseURL - finalURL.Path = r.path + finalURL.Path = p + query := url.Values{} for key, value := range r.params { query.Add(key, value) } + if !r.namespaceInPath && len(r.namespace) > 0 { + query.Add("namespace", r.namespace) + } + // sync and timeout are handled specially here, to allow setting them // in any order. if r.sync { @@ -452,13 +515,12 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) ([]b switch resp.StatusCode { case http.StatusConflict: if req.Method == "POST" { - // TODO: add Resource() and ResourceName() as Request methods so that we can set these - err = errors.NewAlreadyExists("", "") + err = errors.NewAlreadyExists(r.resource, r.resourceName) } else { - err = errors.NewConflict("", "", err) + err = errors.NewConflict(r.resource, r.resourceName, err) } case http.StatusNotFound: - err = errors.NewNotFound("", "") + err = errors.NewNotFound(r.resource, r.resourceName) case http.StatusBadRequest: err = errors.NewBadRequest(err.Error()) } From e355f54edad78bd50b7f77ab79543c91e8b16b7a Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Fri, 26 Dec 2014 15:06:25 -0500 Subject: [PATCH 2/2] Update references from Path() to the appropriate segment use --- cmd/e2e/e2e.go | 15 +- cmd/integration/integration.go | 24 ++-- cmd/kubecfg/kubecfg.go | 4 +- pkg/client/endpoints.go | 14 +- pkg/client/events.go | 12 +- pkg/client/minions.go | 8 +- pkg/client/pods.go | 10 +- pkg/client/replication_controllers.go | 14 +- pkg/client/request_test.go | 177 ++++++++++++++++++++++-- pkg/client/restclient.go | 6 +- pkg/client/restclient_test.go | 6 +- pkg/client/services.go | 14 +- pkg/config/config.go | 2 +- pkg/kubecfg/validate.go | 2 +- pkg/kubectl/cmd/cmd.go | 3 +- pkg/kubectl/cmd/log.go | 10 +- pkg/kubectl/resthelper.go | 20 +-- pkg/kubectl/resthelper_test.go | 2 +- pkg/ui/datafile.go | 14 +- plugin/pkg/scheduler/factory/factory.go | 12 +- 20 files changed, 258 insertions(+), 111 deletions(-) diff --git a/cmd/e2e/e2e.go b/cmd/e2e/e2e.go index f987fd8ab38..2543f6b5a72 100644 --- a/cmd/e2e/e2e.go +++ b/cmd/e2e/e2e.go @@ -332,7 +332,7 @@ func TestNetwork(c *client.Client) bool { const maxAttempts = 60 for i := 0; i < maxAttempts; i++ { time.Sleep(time.Second) - body, err := c.Get().Path("proxy").Path("services").Path(svc.Name).Path("status").Do().Raw() + body, err := c.Get().Prefix("proxy").Resource("services").Name(svc.Name).Suffix("status").Do().Raw() if err != nil { glog.Infof("Attempt %v/%v: service/pod still starting. (error: '%v')", i, maxAttempts, err) continue @@ -344,7 +344,7 @@ func TestNetwork(c *client.Client) bool { case "running": glog.Infof("Attempt %v/%v: test still running", i, maxAttempts) case "fail": - if body, err := c.Get().Path("proxy").Path("services").Path(svc.Name).Path("read").Do().Raw(); err != nil { + if body, err := c.Get().Prefix("proxy").Resource("services").Name(svc.Name).Suffix("read").Do().Raw(); err != nil { glog.Infof("Failed on attempt %v. Cleaning up. Error reading details: %v", i, err) } else { glog.Infof("Failed on attempt %v. Cleaning up. Details:\n%v", i, string(body)) @@ -353,7 +353,7 @@ func TestNetwork(c *client.Client) bool { } } - if body, err := c.Get().Path("proxy").Path("services").Path(svc.Name).Path("read").Do().Raw(); err != nil { + if body, err := c.Get().Prefix("proxy").Resource("services").Name(svc.Name).Suffix("read").Do().Raw(); err != nil { glog.Infof("Timed out. Cleaning up. Error reading details: %v", err) } else { glog.Infof("Timed out. Cleaning up. Details:\n%v", string(body)) @@ -472,12 +472,11 @@ func TestClusterDNS(c *client.Client) bool { failed = []string{} for _, name := range namesToResolve { _, err := c.Get(). - Path("proxy"). + Prefix("proxy"). + Resource("pods"). Namespace("default"). - Path("pods"). - Path(pod.Name). - Path("results"). - Path(name). + Name(pod.Name). + Suffix("results", name). Do().Raw() if err != nil { failed = append(failed, name) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 39744e3dd17..8579ee157a3 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -279,7 +279,7 @@ func runAPIVersionsTest(c *client.Client) { func runSelfLinkTest(c *client.Client) { var svc api.Service - err := c.Post().Path("services").Body( + err := c.Post().Resource("services").Body( &api.Service{ ObjectMeta: api.ObjectMeta{ Name: "selflinktest", @@ -305,7 +305,7 @@ func runSelfLinkTest(c *client.Client) { } var svcList api.ServiceList - err = c.Get().Path("services").Do().Into(&svcList) + err = c.Get().Resource("services").Do().Into(&svcList) if err != nil { glog.Fatalf("Failed listing services: %v", err) } @@ -338,7 +338,7 @@ func runSelfLinkTest(c *client.Client) { func runAtomicPutTest(c *client.Client) { var svc api.Service - err := c.Post().Path("services").Body( + err := c.Post().Resource("services").Body( &api.Service{ TypeMeta: api.TypeMeta{ APIVersion: latest.Version, @@ -377,8 +377,8 @@ func runAtomicPutTest(c *client.Client) { glog.Infof("Starting to update (%s, %s)", l, v) var tmpSvc api.Service err := c.Get(). - Path("services"). - Path(svc.Name). + Resource("services"). + Name(svc.Name). Do(). Into(&tmpSvc) if err != nil { @@ -391,7 +391,7 @@ func runAtomicPutTest(c *client.Client) { tmpSvc.Spec.Selector[l] = v } glog.Infof("Posting update (%s, %s)", l, v) - err = c.Put().Path("services").Path(svc.Name).Body(&tmpSvc).Do().Error() + err = c.Put().Resource("services").Name(svc.Name).Body(&tmpSvc).Do().Error() if err != nil { if errors.IsConflict(err) { glog.Infof("Conflict: (%s, %s)", l, v) @@ -408,7 +408,7 @@ func runAtomicPutTest(c *client.Client) { }(label, value) } wg.Wait() - if err := c.Get().Path("services").Path(svc.Name).Do().Into(&svc); err != nil { + if err := c.Get().Resource("services").Name(svc.Name).Do().Into(&svc); err != nil { glog.Fatalf("Failed getting atomicService after writers are complete: %v", err) } if !reflect.DeepEqual(testLabels, labels.Set(svc.Spec.Selector)) { @@ -422,7 +422,7 @@ func runMasterServiceTest(client *client.Client) { var svcList api.ServiceList err := client.Get(). Namespace("default"). - Path("services"). + Resource("services"). Do(). Into(&svcList) if err != nil { @@ -443,8 +443,8 @@ func runMasterServiceTest(client *client.Client) { var ep api.Endpoints err := client.Get(). Namespace("default"). - Path("endpoints"). - Path("kubernetes"). + Resource("endpoints"). + Name("kubernetes"). Do(). Into(&ep) if err != nil { @@ -460,8 +460,8 @@ func runMasterServiceTest(client *client.Client) { var ep api.Endpoints err := client.Get(). Namespace("default"). - Path("endpoints"). - Path("kubernetes-ro"). + Resource("endpoints"). + Name("kubernetes-ro"). Do(). Into(&ep) if err != nil { diff --git a/cmd/kubecfg/kubecfg.go b/cmd/kubecfg/kubecfg.go index 1a4a15ae564..13f88f14e8f 100644 --- a/cmd/kubecfg/kubecfg.go +++ b/cmd/kubecfg/kubecfg.go @@ -378,7 +378,7 @@ func executeAPIRequest(ctx api.Context, method string, c *client.Client) bool { glog.Fatalf("usage: kubecfg [OPTIONS] %s <%s>", method, prettyWireStorage()) } case "update": - obj, err := c.Verb("GET").Namespace(api.Namespace(ctx)).Path(path).Do().Get() + obj, err := c.Verb("GET").Namespace(api.Namespace(ctx)).Suffix(path).Do().Get() if err != nil { glog.Fatalf("error obtaining resource version for update: %v", err) } @@ -404,7 +404,7 @@ func executeAPIRequest(ctx api.Context, method string, c *client.Client) bool { return false } - r := c.Verb(verb).Namespace(api.Namespace(ctx)).Path(path) + r := c.Verb(verb).Namespace(api.Namespace(ctx)).Suffix(path) if len(*selector) > 0 { r.ParseSelectorParam("labels", *selector) } diff --git a/pkg/client/endpoints.go b/pkg/client/endpoints.go index 85e38a1bb2a..9a83389971d 100644 --- a/pkg/client/endpoints.go +++ b/pkg/client/endpoints.go @@ -53,14 +53,14 @@ func newEndpoints(c *Client, namespace string) *endpoints { // Create creates a new endpoint. func (c *endpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error) { result := &api.Endpoints{} - err := c.r.Post().Namespace(c.ns).Path("endpoints").Body(endpoints).Do().Into(result) + err := c.r.Post().Namespace(c.ns).Resource("endpoints").Body(endpoints).Do().Into(result) return result, err } // List takes a selector, and returns the list of endpoints that match that selector func (c *endpoints) List(selector labels.Selector) (result *api.EndpointsList, err error) { result = &api.EndpointsList{} - err = c.r.Get().Namespace(c.ns).Path("endpoints").SelectorParam("labels", selector).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("endpoints").SelectorParam("labels", selector).Do().Into(result) return } @@ -71,16 +71,16 @@ func (c *endpoints) Get(name string) (result *api.Endpoints, err error) { } result = &api.Endpoints{} - err = c.r.Get().Namespace(c.ns).Path("endpoints").Path(name).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("endpoints").Name(name).Do().Into(result) return } // Watch returns a watch.Interface that watches the requested endpoints for a service. func (c *endpoints) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { return c.r.Get(). - Path("watch"). + Prefix("watch"). Namespace(c.ns). - Path("endpoints"). + Resource("endpoints"). Param("resourceVersion", resourceVersion). SelectorParam("labels", label). SelectorParam("fields", field). @@ -94,8 +94,8 @@ func (c *endpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) { } err := c.r.Put(). Namespace(c.ns). - Path("endpoints"). - Path(endpoints.Name). + Resource("endpoints"). + Name(endpoints.Name). Body(endpoints). Do(). Into(result) diff --git a/pkg/client/events.go b/pkg/client/events.go index e938d6b451f..11464056adf 100644 --- a/pkg/client/events.go +++ b/pkg/client/events.go @@ -66,7 +66,7 @@ func (e *events) Create(event *api.Event) (*api.Event, error) { result := &api.Event{} err := e.client.Post(). Namespace(event.Namespace). - Path("events"). + Resource("events"). Body(event). Do(). Into(result) @@ -78,7 +78,7 @@ func (e *events) List(label, field labels.Selector) (*api.EventList, error) { result := &api.EventList{} err := e.client.Get(). Namespace(e.namespace). - Path("events"). + Resource("events"). SelectorParam("labels", label). SelectorParam("fields", field). Do(). @@ -95,8 +95,8 @@ func (e *events) Get(name string) (*api.Event, error) { result := &api.Event{} err := e.client.Get(). Namespace(e.namespace). - Path("events"). - Path(name). + Resource("events"). + Name(name). Do(). Into(result) return result, err @@ -105,9 +105,9 @@ func (e *events) Get(name string) (*api.Event, error) { // Watch starts watching for events matching the given selectors. func (e *events) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { return e.client.Get(). - Path("watch"). + Prefix("watch"). Namespace(e.namespace). - Path("events"). + Resource("events"). Param("resourceVersion", resourceVersion). SelectorParam("labels", label). SelectorParam("fields", field). diff --git a/pkg/client/minions.go b/pkg/client/minions.go index 07ec4dc664a..e4f88edac59 100644 --- a/pkg/client/minions.go +++ b/pkg/client/minions.go @@ -55,14 +55,14 @@ func (c *nodes) resourceName() string { // Create creates a new minion. func (c *nodes) Create(minion *api.Node) (*api.Node, error) { result := &api.Node{} - err := c.r.Post().Path(c.resourceName()).Body(minion).Do().Into(result) + err := c.r.Post().Resource(c.resourceName()).Body(minion).Do().Into(result) return result, err } // List lists all the nodes in the cluster. func (c *nodes) List() (*api.NodeList, error) { result := &api.NodeList{} - err := c.r.Get().Path(c.resourceName()).Do().Into(result) + err := c.r.Get().Resource(c.resourceName()).Do().Into(result) return result, err } @@ -73,11 +73,11 @@ func (c *nodes) Get(name string) (*api.Node, error) { } result := &api.Node{} - err := c.r.Get().Path(c.resourceName()).Path(name).Do().Into(result) + err := c.r.Get().Resource(c.resourceName()).Name(name).Do().Into(result) return result, err } // Delete deletes an existing minion. func (c *nodes) Delete(name string) error { - return c.r.Delete().Path(c.resourceName()).Path(name).Do().Error() + return c.r.Delete().Resource(c.resourceName()).Name(name).Do().Error() } diff --git a/pkg/client/pods.go b/pkg/client/pods.go index 2250e13c154..0e98ce4f6f7 100644 --- a/pkg/client/pods.go +++ b/pkg/client/pods.go @@ -55,7 +55,7 @@ func newPods(c *Client, namespace string) *pods { // ListPods takes a selector, and returns the list of pods that match that selector. func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) { result = &api.PodList{} - err = c.r.Get().Namespace(c.ns).Path("pods").SelectorParam("labels", selector).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("pods").SelectorParam("labels", selector).Do().Into(result) return } @@ -66,19 +66,19 @@ func (c *pods) Get(name string) (result *api.Pod, err error) { } result = &api.Pod{} - err = c.r.Get().Namespace(c.ns).Path("pods").Path(name).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("pods").Name(name).Do().Into(result) return } // DeletePod takes the name of the pod, and returns an error if one occurs func (c *pods) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Path("pods").Path(name).Do().Error() + return c.r.Delete().Namespace(c.ns).Resource("pods").Name(name).Do().Error() } // CreatePod takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs. func (c *pods) Create(pod *api.Pod) (result *api.Pod, err error) { result = &api.Pod{} - err = c.r.Post().Namespace(c.ns).Path("pods").Body(pod).Do().Into(result) + err = c.r.Post().Namespace(c.ns).Resource("pods").Body(pod).Do().Into(result) return } @@ -89,6 +89,6 @@ func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) { err = fmt.Errorf("invalid update object, missing resource version: %v", pod) return } - err = c.r.Put().Namespace(c.ns).Path("pods").Path(pod.Name).Body(pod).Do().Into(result) + err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).Body(pod).Do().Into(result) return } diff --git a/pkg/client/replication_controllers.go b/pkg/client/replication_controllers.go index fcde561f367..10f902e6d9c 100644 --- a/pkg/client/replication_controllers.go +++ b/pkg/client/replication_controllers.go @@ -54,7 +54,7 @@ func newReplicationControllers(c *Client, namespace string) *replicationControll // List takes a selector, and returns the list of replication controllers that match that selector. func (c *replicationControllers) List(selector labels.Selector) (result *api.ReplicationControllerList, err error) { result = &api.ReplicationControllerList{} - err = c.r.Get().Namespace(c.ns).Path("replicationControllers").SelectorParam("labels", selector).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").SelectorParam("labels", selector).Do().Into(result) return } @@ -65,14 +65,14 @@ func (c *replicationControllers) Get(name string) (result *api.ReplicationContro } result = &api.ReplicationController{} - err = c.r.Get().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").Name(name).Do().Into(result) return } // Create creates a new replication controller. func (c *replicationControllers) Create(controller *api.ReplicationController) (result *api.ReplicationController, err error) { result = &api.ReplicationController{} - err = c.r.Post().Namespace(c.ns).Path("replicationControllers").Body(controller).Do().Into(result) + err = c.r.Post().Namespace(c.ns).Resource("replicationControllers").Body(controller).Do().Into(result) return } @@ -83,21 +83,21 @@ func (c *replicationControllers) Update(controller *api.ReplicationController) ( err = fmt.Errorf("invalid update object, missing resource version: %v", controller) return } - err = c.r.Put().Namespace(c.ns).Path("replicationControllers").Path(controller.Name).Body(controller).Do().Into(result) + err = c.r.Put().Namespace(c.ns).Resource("replicationControllers").Name(controller.Name).Body(controller).Do().Into(result) return } // Delete deletes an existing replication controller. func (c *replicationControllers) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Path("replicationControllers").Path(name).Do().Error() + return c.r.Delete().Namespace(c.ns).Resource("replicationControllers").Name(name).Do().Error() } // Watch returns a watch.Interface that watches the requested controllers. func (c *replicationControllers) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { return c.r.Get(). - Path("watch"). + Prefix("watch"). Namespace(c.ns). - Path("replicationControllers"). + Resource("replicationControllers"). Param("resourceVersion", resourceVersion). SelectorParam("labels", label). SelectorParam("fields", field). diff --git a/pkg/client/request_test.go b/pkg/client/request_test.go index ef04e9362d8..f8d25072d4e 100644 --- a/pkg/client/request_test.go +++ b/pkg/client/request_test.go @@ -32,6 +32,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + apierrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" @@ -54,9 +55,12 @@ func TestRequestWithErrorWontChange(t *testing.T) { SelectorParam("labels", labels.Set{"a": "b"}.AsSelector()). UintParam("uint", 1). AbsPath("/abs"). - Path("test"). + Prefix("test"). + Suffix("testing"). ParseSelectorParam("foo", "a=b"). Namespace("new"). + Resource("foos"). + Name("bars"). NoPoll(). Body("foo"). Poller(skipPolling). @@ -70,6 +74,74 @@ func TestRequestWithErrorWontChange(t *testing.T) { } } +func TestRequestPreservesBaseTrailingSlash(t *testing.T) { + r := &Request{baseURL: &url.URL{}, path: "/path/"} + if s := r.finalURL(); s != "/path/" { + t.Errorf("trailing slash should be preserved: %s", s) + } +} + +func TestRequestAbsPathPreservesTrailingSlash(t *testing.T) { + r := (&Request{baseURL: &url.URL{}}).AbsPath("/foo/") + if s := r.finalURL(); s != "/foo/" { + t.Errorf("trailing slash should be preserved: %s", s) + } +} + +func TestRequestAbsPathJoins(t *testing.T) { + r := (&Request{baseURL: &url.URL{}}).AbsPath("foo/bar", "baz") + if s := r.finalURL(); s != "foo/bar/baz" { + t.Errorf("trailing slash should be preserved: %s", s) + } +} + +func TestRequestSetsNamespace(t *testing.T) { + r := (&Request{ + baseURL: &url.URL{ + Path: "/", + }, + }).Namespace("foo") + if r.namespace == "" { + t.Errorf("namespace should be set: %#v", r) + } + if s := r.finalURL(); s != "?namespace=foo" { + t.Errorf("namespace should be in params: %s", s) + } + + r = (&Request{ + baseURL: &url.URL{ + Path: "/", + }, + namespaceInPath: true, + }).Namespace("foo") + if s := r.finalURL(); s != "ns/foo" { + t.Errorf("namespace should be in path: %s", s) + } +} + +func TestRequestOrdersNamespaceInPath(t *testing.T) { + r := (&Request{ + baseURL: &url.URL{}, + path: "/test/", + namespaceInPath: true, + }).Name("bar").Resource("baz").Namespace("foo") + if s := r.finalURL(); s != "/test/ns/foo/baz/bar" { + t.Errorf("namespace should be in order in path: %s", s) + } +} + +func TestRequestSetTwiceError(t *testing.T) { + if (&Request{}).Name("bar").Name("baz").err == nil { + t.Errorf("setting name twice should result in error") + } + if (&Request{}).Namespace("bar").Namespace("baz").err == nil { + t.Errorf("setting namespace twice should result in error") + } + if (&Request{}).Resource("bar").Resource("baz").err == nil { + t.Errorf("setting resource twice should result in error") + } +} + func TestRequestParseSelectorParam(t *testing.T) { r := (&Request{}).ParseSelectorParam("foo", "a") if r.err == nil || r.params != nil { @@ -133,6 +205,9 @@ func TestTransformResponse(t *testing.T) { {Response: &http.Response{StatusCode: 201}, Data: []byte{}, Created: true}, {Response: &http.Response{StatusCode: 199}, Error: true}, {Response: &http.Response{StatusCode: 500}, Error: true}, + {Response: &http.Response{StatusCode: 422}, Error: true}, + {Response: &http.Response{StatusCode: 409}, Error: true}, + {Response: &http.Response{StatusCode: 404}, Error: true}, {Response: &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewReader(invalid))}, Data: invalid}, {Response: &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewReader(invalid))}, Data: invalid}, } @@ -155,6 +230,80 @@ func TestTransformResponse(t *testing.T) { } } +func TestTransformUnstructuredError(t *testing.T) { + testCases := []struct { + Req *http.Request + Res *http.Response + + Resource string + Name string + + ErrFn func(error) bool + }{ + { + Resource: "foo", + Name: "bar", + Req: &http.Request{ + Method: "POST", + }, + Res: &http.Response{ + StatusCode: http.StatusConflict, + Body: ioutil.NopCloser(bytes.NewReader(nil)), + }, + ErrFn: apierrors.IsAlreadyExists, + }, + { + Resource: "foo", + Name: "bar", + Req: &http.Request{ + Method: "PUT", + }, + Res: &http.Response{ + StatusCode: http.StatusConflict, + Body: ioutil.NopCloser(bytes.NewReader(nil)), + }, + ErrFn: apierrors.IsConflict, + }, + { + Resource: "foo", + Name: "bar", + Req: &http.Request{}, + Res: &http.Response{ + StatusCode: http.StatusNotFound, + Body: ioutil.NopCloser(bytes.NewReader(nil)), + }, + ErrFn: apierrors.IsNotFound, + }, + { + Req: &http.Request{}, + Res: &http.Response{ + StatusCode: http.StatusBadRequest, + Body: ioutil.NopCloser(bytes.NewReader(nil)), + }, + ErrFn: apierrors.IsBadRequest, + }, + } + + for _, testCase := range testCases { + r := &Request{ + codec: latest.Codec, + resourceName: testCase.Name, + resource: testCase.Resource, + } + _, _, err := r.transformResponse(testCase.Res, testCase.Req) + if !testCase.ErrFn(err) { + t.Errorf("unexpected error: %v", err) + continue + } + if len(testCase.Name) != 0 && !strings.Contains(err.Error(), testCase.Name) { + t.Errorf("unexpected error string: %s", err) + } + if len(testCase.Resource) != 0 && !strings.Contains(err.Error(), testCase.Resource) { + t.Errorf("unexpected error string: %s", err) + } + } +} + type clientFunc func(req *http.Request) (*http.Response, error) func (f clientFunc) Do(req *http.Request) (*http.Response, error) { @@ -333,8 +482,8 @@ func TestDoRequestNewWay(t *testing.T) { defer testServer.Close() c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta2", Username: "user", Password: "pass"}) obj, err := c.Verb("POST"). - Path("foo/bar"). - Path("baz"). + Prefix("foo", "bar"). + Suffix("baz"). ParseSelectorParam("labels", "name=foo"). Timeout(time.Second). Body([]byte(reqBody)). @@ -367,8 +516,9 @@ func TestDoRequestNewWayReader(t *testing.T) { testServer := httptest.NewServer(&fakeHandler) c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta1", Username: "user", Password: "pass"}) obj, err := c.Verb("POST"). - Path("foo/bar"). - Path("baz"). + Resource("bar"). + Name("baz"). + Prefix("foo"). SelectorParam("labels", labels.Set{"name": "foo"}.AsSelector()). Sync(true). Timeout(time.Second). @@ -403,8 +553,9 @@ func TestDoRequestNewWayObj(t *testing.T) { testServer := httptest.NewServer(&fakeHandler) c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta2", Username: "user", Password: "pass"}) obj, err := c.Verb("POST"). - Path("foo/bar"). - Path("baz"). + Suffix("baz"). + Name("bar"). + Resource("foo"). SelectorParam("labels", labels.Set{"name": "foo"}.AsSelector()). Timeout(time.Second). Body(reqObj). @@ -453,8 +604,7 @@ func TestDoRequestNewWayFile(t *testing.T) { c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta1", Username: "user", Password: "pass"}) wasCreated := true obj, err := c.Verb("POST"). - Path("foo/bar"). - Path("baz"). + Prefix("foo/bar", "baz"). ParseSelectorParam("labels", "name=foo"). Timeout(time.Second). Body(file.Name()). @@ -496,8 +646,7 @@ func TestWasCreated(t *testing.T) { c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta1", Username: "user", Password: "pass"}) wasCreated := false obj, err := c.Verb("PUT"). - Path("foo/bar"). - Path("baz"). + Prefix("foo/bar", "baz"). ParseSelectorParam("labels", "name=foo"). Timeout(time.Second). Body(reqBodyExpected). @@ -541,7 +690,7 @@ func TestVerbs(t *testing.T) { func TestAbsPath(t *testing.T) { expectedPath := "/bar/foo" c := NewOrDie(&Config{}) - r := c.Post().Path("/foo").AbsPath(expectedPath) + r := c.Post().Prefix("/foo").AbsPath(expectedPath) if r.path != expectedPath { t.Errorf("unexpected path: %s, expected %s", r.path, expectedPath) } @@ -792,7 +941,7 @@ func TestWatch(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - watching, err := s.Get().Path("path/to/watch/thing").Watch() + watching, err := s.Get().Prefix("path/to/watch/thing").Watch() if err != nil { t.Fatalf("Unexpected error") } @@ -841,7 +990,7 @@ func TestStream(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - readCloser, err := s.Get().Path("path/to/stream/thing").Stream() + readCloser, err := s.Get().Prefix("path/to/stream/thing").Stream() if err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/pkg/client/restclient.go b/pkg/client/restclient.go index 926e43b1d64..581a75bbfc1 100644 --- a/pkg/client/restclient.go +++ b/pkg/client/restclient.go @@ -59,7 +59,9 @@ type RESTClient struct { // NewRESTClient creates a new RESTClient. This client performs generic REST functions // such as Get, Put, Post, and Delete on specified paths. Codec controls encoding and -// decoding of responses from the server. +// decoding of responses from the server. If the namespace should be specified as part +// of the path (after the resource), set namespaceInPath to true, otherwise it will be +// passed as "namespace" in the query string. func NewRESTClient(baseURL *url.URL, c runtime.Codec, namespaceInPath bool) *RESTClient { base := *baseURL if !strings.HasSuffix(base.Path, "/") { @@ -129,7 +131,7 @@ func (c *RESTClient) Delete() *Request { // PollFor makes a request to do a single poll of the completion of the given operation. func (c *RESTClient) Operation(name string) *Request { - return c.Get().Path("operations").Path(name).Sync(false).NoPoll() + return c.Get().Resource("operations").Name(name).Sync(false).NoPoll() } func (c *RESTClient) DefaultPoll(name string) (*Request, bool) { diff --git a/pkg/client/restclient_test.go b/pkg/client/restclient_test.go index 41d3f8d60da..b859aced001 100644 --- a/pkg/client/restclient_test.go +++ b/pkg/client/restclient_test.go @@ -137,7 +137,7 @@ func TestDoRequestAccepted(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - body, err := c.Get().Path("test").Do().Raw() + body, err := c.Get().Prefix("test").Do().Raw() if err == nil { t.Fatalf("Unexpected non-error") } @@ -171,7 +171,7 @@ func TestDoRequestAcceptedSuccess(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - body, err := c.Get().Path("test").Do().Raw() + body, err := c.Get().Prefix("test").Do().Raw() if err != nil { t.Fatalf("unexpected error: %v", err) } @@ -231,7 +231,7 @@ func TestDoRequestCreated(t *testing.T) { t.Fatalf("unexpected error: %v", err) } created := false - body, err := c.Get().Path("test").Do().WasCreated(&created).Raw() + body, err := c.Get().Prefix("test").Do().WasCreated(&created).Raw() if err != nil { t.Errorf("Unexpected error %#v", err) } diff --git a/pkg/client/services.go b/pkg/client/services.go index 1a73a726f8d..15c39fa9ce4 100644 --- a/pkg/client/services.go +++ b/pkg/client/services.go @@ -54,7 +54,7 @@ func newServices(c *Client, namespace string) *services { // List takes a selector, and returns the list of services that match that selector func (c *services) List(selector labels.Selector) (result *api.ServiceList, err error) { result = &api.ServiceList{} - err = c.r.Get().Namespace(c.ns).Path("services").SelectorParam("labels", selector).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("services").SelectorParam("labels", selector).Do().Into(result) return } @@ -65,14 +65,14 @@ func (c *services) Get(name string) (result *api.Service, err error) { } result = &api.Service{} - err = c.r.Get().Namespace(c.ns).Path("services").Path(name).Do().Into(result) + err = c.r.Get().Namespace(c.ns).Resource("services").Name(name).Do().Into(result) return } // Create creates a new service. func (c *services) Create(svc *api.Service) (result *api.Service, err error) { result = &api.Service{} - err = c.r.Post().Namespace(c.ns).Path("services").Body(svc).Do().Into(result) + err = c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result) return } @@ -83,21 +83,21 @@ func (c *services) Update(svc *api.Service) (result *api.Service, err error) { err = fmt.Errorf("invalid update object, missing resource version: %v", svc) return } - err = c.r.Put().Namespace(c.ns).Path("services").Path(svc.Name).Body(svc).Do().Into(result) + err = c.r.Put().Namespace(c.ns).Resource("services").Name(svc.Name).Body(svc).Do().Into(result) return } // Delete deletes an existing service. func (c *services) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Path("services").Path(name).Do().Error() + return c.r.Delete().Namespace(c.ns).Resource("services").Name(name).Do().Error() } // Watch returns a watch.Interface that watches the requested services. func (c *services) Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error) { return c.r.Get(). - Path("watch"). + Prefix("watch"). Namespace(c.ns). - Path("services"). + Resource("services"). Param("resourceVersion", resourceVersion). SelectorParam("labels", label). SelectorParam("fields", field). diff --git a/pkg/config/config.go b/pkg/config/config.go index 3a66498f02b..0b764beedd8 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -80,7 +80,7 @@ func CreateObject(client RESTClientPoster, mapping *meta.RESTMapping, obj runtim } // TODO: This should be using RESTHelper - err = client.Post().Path(mapping.Resource).Namespace(namespace).Body(obj).Do().Error() + err = client.Post().Resource(mapping.Resource).Namespace(namespace).Body(obj).Do().Error() if err != nil { return errs.NewFieldInvalid(name, obj, err.Error()) } diff --git a/pkg/kubecfg/validate.go b/pkg/kubecfg/validate.go index b13175f0339..aa6d2535a38 100644 --- a/pkg/kubecfg/validate.go +++ b/pkg/kubecfg/validate.go @@ -37,7 +37,7 @@ func ValidateObject(data []byte, c *client.Client) error { schemaData, err := c.RESTClient.Get(). AbsPath("/swaggerapi/api"). - Path(apiVersion.(string)). + Prefix(apiVersion.(string)). Do(). Raw() if err != nil { diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index 50ce9b710f6..6547ae56e66 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -183,8 +183,7 @@ func (c *clientSwaggerSchema) ValidateBytes(data []byte) error { return err } schemaData, err := c.c.RESTClient.Get(). - AbsPath("/swaggerapi/api"). - Path(version). + AbsPath("/swaggerapi/api", version). Do(). Raw() if err != nil { diff --git a/pkg/kubectl/cmd/log.go b/pkg/kubectl/cmd/log.go index fed160cc784..91e5b79f48f 100644 --- a/pkg/kubectl/cmd/log.go +++ b/pkg/kubectl/cmd/log.go @@ -70,12 +70,10 @@ Examples: } readCloser, err := client.RESTClient.Get(). - Path("proxy/minions"). - Path(pod.Status.Host). - Path("containerLogs"). - Path(namespace). - Path(podID). - Path(container). + Prefix("proxy"). + Resource("minions"). + Name(pod.Status.Host). + Suffix("containerLogs", namespace, podID, container). Param("follow", strconv.FormatBool(follow)). Stream() checkErr(err) diff --git a/pkg/kubectl/resthelper.go b/pkg/kubectl/resthelper.go index f7e7580faa4..defe294be0d 100644 --- a/pkg/kubectl/resthelper.go +++ b/pkg/kubectl/resthelper.go @@ -47,18 +47,18 @@ func NewRESTHelper(client RESTClient, mapping *meta.RESTMapping) *RESTHelper { } func (m *RESTHelper) Get(namespace, name string, selector labels.Selector) (runtime.Object, error) { - return m.RESTClient.Get().Namespace(namespace).Path(m.Resource).Path(name).SelectorParam("labels", selector).Do().Get() + return m.RESTClient.Get().Resource(m.Resource).Namespace(namespace).Name(name).SelectorParam("labels", selector).Do().Get() } func (m *RESTHelper) List(namespace string, selector labels.Selector) (runtime.Object, error) { - return m.RESTClient.Get().Path(m.Resource).Namespace(namespace).Path("").SelectorParam("labels", selector).Do().Get() + return m.RESTClient.Get().Resource(m.Resource).Namespace(namespace).SelectorParam("labels", selector).Do().Get() } func (m *RESTHelper) Watch(namespace, resourceVersion string, labelSelector, fieldSelector labels.Selector) (watch.Interface, error) { return m.RESTClient.Get(). - Path("watch"). + Prefix("watch"). Namespace(namespace). - Path(m.Resource). + Resource(m.Resource). Param("resourceVersion", resourceVersion). SelectorParam("labels", labelSelector). SelectorParam("fields", fieldSelector). @@ -66,7 +66,7 @@ func (m *RESTHelper) Watch(namespace, resourceVersion string, labelSelector, fie } func (m *RESTHelper) Delete(namespace, name string) error { - return m.RESTClient.Delete().Namespace(namespace).Path(m.Resource).Path(name).Do().Error() + return m.RESTClient.Delete().Namespace(namespace).Resource(m.Resource).Name(name).Do().Error() } func (m *RESTHelper) Create(namespace string, modify bool, data []byte) error { @@ -98,8 +98,8 @@ func (m *RESTHelper) Create(namespace string, modify bool, data []byte) error { return createResource(m.RESTClient, m.Resource, namespace, data) } -func createResource(c RESTClient, resourcePath, namespace string, data []byte) error { - return c.Post().Namespace(namespace).Path(resourcePath).Body(data).Do().Error() +func createResource(c RESTClient, resource, namespace string, data []byte) error { + return c.Post().Namespace(namespace).Resource(resource).Body(data).Do().Error() } func (m *RESTHelper) Update(namespace, name string, overwrite bool, data []byte) error { @@ -119,7 +119,7 @@ func (m *RESTHelper) Update(namespace, name string, overwrite bool, data []byte) } if version == "" && overwrite { // Retrieve the current version of the object to overwrite the server object - serverObj, err := c.Get().Path(m.Resource).Path(name).Do().Get() + serverObj, err := c.Get().Resource(m.Resource).Name(name).Do().Get() if err != nil { // The object does not exist, but we want it to be created return updateResource(c, m.Resource, namespace, name, data) @@ -141,6 +141,6 @@ func (m *RESTHelper) Update(namespace, name string, overwrite bool, data []byte) return updateResource(c, m.Resource, namespace, name, data) } -func updateResource(c RESTClient, resourcePath, namespace, name string, data []byte) error { - return c.Put().Namespace(namespace).Path(resourcePath).Path(name).Body(data).Do().Error() +func updateResource(c RESTClient, resource, namespace, name string, data []byte) error { + return c.Put().Namespace(namespace).Resource(resource).Name(name).Body(data).Do().Error() } diff --git a/pkg/kubectl/resthelper_test.go b/pkg/kubectl/resthelper_test.go index 25e942c037c..5aa25ab25b9 100644 --- a/pkg/kubectl/resthelper_test.go +++ b/pkg/kubectl/resthelper_test.go @@ -287,7 +287,7 @@ func TestRESTHelperUpdate(t *testing.T) { } parts := splitPath(req.URL.Path) if parts[1] != "bar" { - t.Errorf("url doesn't contain namespace: %#v", req) + t.Errorf("url doesn't contain namespace: %#v", req.URL) return false } if parts[2] != "foo" { diff --git a/pkg/ui/datafile.go b/pkg/ui/datafile.go index 8a15b3a338c..2101491f756 100644 --- a/pkg/ui/datafile.go +++ b/pkg/ui/datafile.go @@ -11797,7 +11797,7 @@ var Docs = { }, toggleEndpointListForResource: function(resource) { - var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); + var elem = $('li#resource_' + Docs.escapeName(resource) + ' ul.endpoints'); if (elem.is(':visible')) { Docs.collapseEndpointListForResource(resource); } else { @@ -11807,7 +11807,7 @@ var Docs = { // Expand resource expandEndpointListForResource: function(resource) { - var resource = Docs.escapeResourceName(resource); + var resource = Docs.escapeName(resource); if (resource == '') { $('.resource ul.endpoints').slideDown(); return; @@ -11821,7 +11821,7 @@ var Docs = { // Collapse resource and mark as explicitly closed collapseEndpointListForResource: function(resource) { - var resource = Docs.escapeResourceName(resource); + var resource = Docs.escapeName(resource); $('li#resource_' + resource).removeClass('active'); var elem = $('li#resource_' + resource + ' ul.endpoints'); @@ -11837,7 +11837,7 @@ var Docs = { return; } - $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + $('li#resource_' + Docs.escapeName(resource) + ' li.operation div.content').each(function() { Docs.expandOperation($(this)); }); }, @@ -11846,7 +11846,7 @@ var Docs = { // Make sure the resource container is open.. Docs.expandEndpointListForResource(resource); - $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + $('li#resource_' + Docs.escapeName(resource) + ' li.operation div.content').each(function() { Docs.collapseOperation($(this)); }); }, @@ -13966,7 +13966,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; OperationView.prototype.toggleOperationContent = function() { var elem; - elem = $('#' + Docs.escapeResourceName(this.model.parentId + "_" + this.model.nickname + "_content")); + elem = $('#' + Docs.escapeName(this.model.parentId + "_" + this.model.nickname + "_content")); if (elem.is(':visible')) { return Docs.collapseOperation(elem); } else { @@ -14391,7 +14391,7 @@ func www_swagger_ui_swagger_ui_js() (*asset, error) { return a, nil } -var _www_swagger_ui_swagger_ui_min_js = []byte(`$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^` + "`" + `{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.apikey_button_view=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="
apply api key
\n
\n
\n
";if(c=d.keyName){c=c.call(k,{hash:{},data:i})}else{c=k.keyName;c=typeof c===f?c.apply(k):c}g+=h(c)+'
\n \n \n
\n
\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.basic_auth_button_view=b(function(f,g,d,c,e){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,f.helpers);e=e||{};return'
\n
\n
\n
Username
\n \n
Password
\n \n \n
\n
\n\n'})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",c,s,i="function",k=this.escapeExpression,q=this;function f(x,w){var t="",v,u;t+='\n
'+k(((v=((v=x.info),v==null||v===false?v:v.title)),typeof v===i?v.apply(x):v))+'
\n
';u=((v=((v=x.info),v==null||v===false?v:v.description)),typeof v===i?v.apply(x):v);if(u||u===0){t+=u}t+="
\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.license),{hash:{},inverse:q.noop,fn:q.program(6,p,w),data:w});if(u||u===0){t+=u}t+="\n ";return t}function d(w,v){var t="",u;t+='';return t}function r(w,v){var t="",u;t+="';return t}function p(w,v){var t="",u;t+="";return t}function o(w,v){var t="",u;t+='\n , api version: '+k(((u=((u=w.info),u==null||u===false?u:u.version)),typeof u===i?u.apply(w):u))+"\n ";return t}function e(w,v){var t="",u;t+='\n \n \n ';return t}j+="
\n ";c=g["if"].call(n,n.info,{hash:{},inverse:q.noop,fn:q.program(1,f,l),data:l});if(c||c===0){j+=c}j+="\n
\n
\n
    \n\n
    \n
    \n
    \n

    [ base url: ";if(c=g.basePath){c=c.call(n,{hash:{},data:l})}else{c=n.basePath;c=typeof c===i?c.apply(n):c}j+=k(c)+"\n ";s=g["if"].call(n,((c=n.info),c==null||c===false?c:c.version),{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(s||s===0){j+=s}j+="]\n ";s=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(s||s===0){j+=s}j+="\n

    \n
    \n
    \n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(j,u,s,o,A){this.compilerInfo=[4,">= 1.0.0"];s=this.merge(s,j.helpers);A=A||{};var t="",k,f,e="function",d=this.escapeExpression,r=this,c=s.blockHelperMissing;function q(C,B){return"deprecated"}function p(C,B){return"\n

    Warning: Deprecated

    \n "}function n(E,D){var B="",C;B+="\n

    Implementation Notes

    \n

    ";if(C=s.description){C=C.call(E,{hash:{},data:D})}else{C=E.description;C=typeof C===e?C.apply(E):C}if(C||C===0){B+=C}B+="

    \n ";return B}function m(C,B){return'\n
    \n '}function i(E,D){var B="",C;B+='\n \n ";return B}function z(F,E){var B="",D,C;B+="\n
    "+d(((D=F.scope),typeof D===e?D.apply(F):D))+"
    \n ";return B}function y(C,B){return"
    "}function x(C,B){return'\n
    \n \n
    \n '}function w(C,B){return'\n

    Response Class

    \n

    \n
    \n
    \n '}function v(C,B){return'\n

    Parameters

    \n \n \n \n \n \n \n \n \n \n \n \n\n \n
    ParameterValueDescriptionParameter TypeData Type
    \n '}function l(C,B){return"\n
    \n

    Response Messages

    \n \n \n \n \n \n \n \n \n \n \n \n
    HTTP Status CodeReasonResponse Model
    \n "}function h(C,B){return"\n "}function g(C,B){return"\n
    \n \n \n \n
    \n "}t+="\n
      \n
    • \n \n \n
    • \n
    \n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n \n
    \n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n \n ";return v}function h(y,x){var v="",w;v+="\n \n
    \n
    \n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n \n ";return v}function r(y,x){var v="",w;v+="\n \n ";return v}p+="";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C["default"],{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n \n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n \n ";return z}function u(C,B){var z="",A;z+="\n \n ";return z}s+="";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"\n\n \n\n";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="\n";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t["default"],{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t["default"],{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z["default"],{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
    \n
    \n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z["default"],{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(r,q){return" : "}function c(t,s){var q="",r;q+="
  • \n Raw\n
  • ";return q}i+="
    \n

    \n ';if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+" ";p={hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k};if(d=f.summary){d=d.call(m,p)}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(!f.summary){d=n.call(m,d,p)}if(d||d===0){i+=d}if(d=f.summary){d=d.call(m,{hash:{},data:k})}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n

    \n
    \n
    \n\n
    \n
    \n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
    \n\n
    \n
    ';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
    \n \n
    \n
    \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var t,k,l,u,x,q,n,m,p,o,j,r,v,s,i,d,b,B,h,g,f,e,c,a,A,z,w={}.hasOwnProperty,y=function(F,D){for(var C in D){if(w.call(D,C)){F[C]=D[C]}}function E(){this.constructor=F}E.prototype=D.prototype;F.prototype=new E();F.__super__=D.prototype;return F};v=(function(D){y(C,D);function C(){s=C.__super__.constructor.apply(this,arguments);return s}C.prototype.dom_id="swagger_ui";C.prototype.options=null;C.prototype.api=null;C.prototype.headerView=null;C.prototype.mainView=null;C.prototype.initialize=function(E){var F=this;if(E==null){E={}}if(E.dom_id!=null){this.dom_id=E.dom_id;delete E.dom_id}if($("#"+this.dom_id)==null){$("body").append('
    ')}this.options=E;this.options.success=function(){return F.render()};this.options.progress=function(G){return F.showMessage(G)};this.options.failure=function(G){if(F.api&&F.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");F.api=new SwaggerApi(F.options);return F.api.build()}else{return F.onLoadFailure(G)}};this.headerView=new u({el:$("#header")});return this.headerView.on("update-swagger-ui",function(G){return F.updateSwaggerUi(G)})};C.prototype.setOption=function(E,F){return this.options[E]=F};C.prototype.getOption=function(E){return this.options[E]};C.prototype.updateSwaggerUi=function(E){this.options.url=E.url;return this.load()};C.prototype.load=function(){var F,E;if((E=this.mainView)!=null){E.clear()}F=this.options.url;if(F.indexOf("http")!==0){F=this.buildUrl(window.location.href.toString(),F)}this.options.url=F;this.headerView.update(F);this.api=new SwaggerClient(this.options);return this.api.build()};C.prototype.collapseAll=function(){return Docs.collapseEndpointListForResource("")};C.prototype.listAll=function(){return Docs.collapseOperationsForResource("")};C.prototype.expandAll=function(){return Docs.expandOperationsForResource("")};C.prototype.render=function(){var E=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new x({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":this.expandAll();break;case"list":this.listAll()}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};C.prototype.buildUrl=function(G,E){var F,H;log("base is "+G);if(E.indexOf("/")===0){H=G.split("/");G=H[0]+"//"+H[2];return G+E}else{F=G.length;if(G.indexOf("?")>-1){F=Math.min(F,G.indexOf("?"))}if(G.indexOf("#")>-1){F=Math.min(F,G.indexOf("#"))}G=G.substring(0,F);if(G.indexOf("/",G.length-1)!==-1){return G+E}return G+"/"+E}};C.prototype.showMessage=function(E){if(E==null){E=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(E)};C.prototype.onLoadFailure=function(E){var F;if(E==null){E=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");F=$("#message-bar").html(E);if(this.options.onFailure!=null){this.options.onFailure(E)}return F};return C})(Backbone.Router);window.SwaggerUi=v;u=(function(D){y(C,D);function C(){i=C.__super__.constructor.apply(this,arguments);return i}C.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};C.prototype.initialize=function(){};C.prototype.showPetStore=function(E){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};C.prototype.showWordnikDev=function(E){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};C.prototype.showCustomOnKeyup=function(E){if(E.keyCode===13){return this.showCustom()}};C.prototype.showCustom=function(E){if(E!=null){E.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};C.prototype.update=function(F,G,E){if(E==null){E=false}$("#input_baseUrl").val(F);if(E){return this.trigger("update-swagger-ui",{url:F})}};return C})(Backbone.View);x=(function(C){var D;y(E,C);function E(){h=E.__super__.constructor.apply(this,arguments);return h}D={alpha:function(G,F){return G.path.localeCompare(F.path)},method:function(G,F){return G.method.localeCompare(F.method)}};E.prototype.initialize=function(J){var I,H,G,F,K,L;if(J==null){J={}}this.model.auths=[];L=this.model.securityDefinitions;for(H in L){K=L[H];I={name:H,type:K.type,value:K};this.model.auths.push(I)}if(this.model.info&&this.model.info.license&&typeof this.model.info.license==="string"){G=this.model.info.license;F=this.model.info.licenseUrl;this.model.info.license={};this.model.info.license.name=G;this.model.info.license.url=F}if(!this.model.info){this.model.info={}}if(!this.model.info.version){this.model.info.version=this.model.apiVersion}if(this.model.swaggerVersion==="2.0"){if("validatorUrl" in J.swaggerOptions){return this.model.validatorUrl=J.swaggerOptions.validatorUrl}else{if(this.model.url.indexOf("localhost")>0){return this.model.validatorUrl=null}else{return this.model.validatorUrl="http://online.swagger.io/validator"}}}};E.prototype.render=function(){var K,N,F,H,G,L,I,M,O,J;if(this.model.securityDefinitions){for(G in this.model.securityDefinitions){K=this.model.securityDefinitions[G];if(K.type==="apiKey"&&$("#apikey_button").length===0){N=new t({model:K}).render().el;$(".auth_main_container").append(N)}if(K.type==="basicAuth"&&$("#basic_auth_button").length===0){N=new k({model:K}).render().el;$(".auth_main_container").append(N)}}}$(this.el).html(Handlebars.templates.main(this.model));I={};F=0;J=this.model.apisArray;for(M=0,O=J.length;MF){O=F-G}if(OE){L=E-I}if(L")}this.model.oauth=null;if(this.model.authorizations){if(Array.isArray(this.model.authorizations)){Q=this.model.authorizations;for(ai=0,T=Q.length;ai0){H[M.name]=M.value}if(M.type==="file"){R=true}}I=K.find("textarea");for(P=0,J=I.length;P0){H[M.name]=M.value}}F=K.find("select");for(O=0,G=F.length;O0){H[M.name]=N}}E.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();E.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(R){return this.handleFileUpload(H,K)}else{return this.model["do"](H,E,this.showCompleteStatus,this.showErrorStatus,this)}}};C.prototype.success=function(E,F){return F.showCompleteStatus(E)};C.prototype.handleFileUpload=function(V,M){var Q,L,G,R,P,O,T,N,K,J,H,U,Y,X,W,I,F,E,Z,S=this;I=M.serializeArray();for(N=0,U=I.length;N0){V[R.name]=R.value}}Q=new FormData();T=0;F=this.model.parameters;for(K=0,Y=F.length;K");$(".request_url pre",$(this.el)).text(this.invocationUrl);P={type:this.model.method,url:this.invocationUrl,headers:G,data:Q,dataType:"json",contentType:false,processData:false,error:function(ab,ac,aa){return S.showErrorStatus(S.wrap(ab),S)},success:function(aa){return S.showResponse(aa,S)},complete:function(aa){return S.showCompleteStatus(S.wrap(aa),S)}};if(window.authorizations){window.authorizations.apply(P)}if(T===0){P.data.append("fake","true")}jQuery.ajax(P);return false};C.prototype.wrap=function(I){var G,J,L,F,K,H,E;L={};J=I.getAllResponseHeaders().split("\r");for(H=0,E=J.length;H0){return G}else{return null}}};C.prototype.hideResponse=function(E){if(E!=null){E.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};C.prototype.showResponse=function(E){var F;F=JSON.stringify(E,null,"\t").replace(/\n/g,"
    ");return $(".response_body",$(this.el)).html(escape(F))};C.prototype.showErrorStatus=function(F,E){return E.showStatus(F)};C.prototype.showCompleteStatus=function(F,E){return E.showStatus(F)};C.prototype.formatXml=function(L){var H,K,F,M,R,N,G,E,P,Q,J,I,O;E=/(>)(<)(\/*)/g;Q=/[ ]*(.*)[ ]+\n/g;H=/(<.+>)(.+\n)/g;L=L.replace(E,"$1\n$2$3").replace(Q,"$1\n").replace(H,"$1\n$2");G=0;K="";R=L.split("\n");F=0;M="other";P={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};J=function(X){var T,S,V,Z,W,U,Y;U={single:Boolean(X.match(/<.+\/>/)),closing:Boolean(X.match(/<\/.+>/)),opening:Boolean(X.match(/<[^!?].*>/))};W=((function(){var aa;aa=[];for(V in U){Y=U[V];if(Y){aa.push(V)}}return aa})())[0];W=W===void 0?"other":W;T=M+"->"+W;M=W;Z="";F+=P[T];Z=((function(){var ab,ac,aa;aa=[];for(S=ab=0,ac=F;0<=ac?abac;S=0<=ac?++ab:--ab){aa.push(" ")}return aa})()).join("");if(T==="opening->closing"){return K=K.substr(0,K.length-1)+X+"\n"}else{return K+=Z+X+"\n"}};for(I=0,O=R.length;I").text("no content");I=$('
    ').append(G)}else{if(P==="application/json"||/\+json$/.test(P)){Q=null;try{Q=JSON.stringify(JSON.parse(N),null,"  ")}catch(O){M=O;Q="can't parse JSON.  Raw result:\n\n"+N}G=$("").text(Q);I=$('
    ').append(G)}else{if(P==="application/xml"||/\+xml$/.test(P)){G=$("").text(this.formatXml(N));I=$('
    ').append(G)}else{if(P==="text/html"){G=$("").html(_.escape(N));I=$('
    ').append(G)}else{if(/^image\//.test(P)){I=$("").attr("src",F)}else{G=$("").text(N);I=$('
    ').append(G)}}}}}L=I;$(".request_url",$(this.el)).html("
    ");$(".request_url pre",$(this.el)).text(F);$(".response_code",$(this.el)).html("
    "+J.status+"
    ");$(".response_body",$(this.el)).html(L);$(".response_headers",$(this.el)).html("
    "+_.escape(JSON.stringify(J.headers,null,"  ")).replace(/\n/g,"
    ")+"
    ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();K=$(".response_body",$(this.el))[0];E=this.options.swaggerOptions;if(E.highlightSizeThreshold&&J.data.length>E.highlightSizeThreshold){return K}else{return hljs.highlightBlock(K)}};C.prototype.toggleOperationContent=function(){var E;E=$("#"+Docs.escapeResourceName(this.model.parentId+"_"+this.model.nickname+"_content"));if(E.is(":visible")){return Docs.collapseOperation(E)}else{return Docs.expandOperation(E)}};return C})(Backbone.View);r=(function(D){y(C,D);function C(){e=C.__super__.constructor.apply(this,arguments);return e}C.prototype.initialize=function(){};C.prototype.render=function(){var F,E,G;G=this.template();$(this.el).html(G(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){F={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};E=new j({model:F,tagName:"div"});$(".model-signature",this.$el).append(E.render().el)}else{$(".model-signature",this.$el).html("")}return this};C.prototype.template=function(){return Handlebars.templates.status_code};return C})(Backbone.View);m=(function(D){y(C,D);function C(){c=C.__super__.constructor.apply(this,arguments);return c}C.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(F,E){if(F.type.toLowerCase()==="array"||F.allowMultiple){return E.fn(this)}else{return E.inverse(this)}})};C.prototype.render=function(){var E,F,I,G,J,H,M,N,L,K;K=this.model.type||this.model.dataType;if(typeof K==="undefined"){H=this.model.schema;if(H&&H["$ref"]){G=H["$ref"];if(G.indexOf("#/definitions/")===0){K=G.substring("#/definitions/".length)}else{K=G}}}this.model.type=K;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(K&&K.toLowerCase()==="file"){this.model.isFile=true}this.model["default"]=this.model["default"]||this.model.defaultValue;if(this.model.allowableValues){this.model.isList=true}L=this.template();$(this.el).html(L(this.model));M={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){N=new j({model:M,tagName:"div"});$(".model-signature",$(this.el)).append(N.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}F=false;if(this.model.isBody){F=true}E={isParam:F};E.consumes=this.model.consumes;if(F){I=new n({model:E});$(".parameter-content-type",$(this.el)).append(I.render().el)}else{J=new o({model:E});$(".response-content-type",$(this.el)).append(J.render().el)}return this};C.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return C})(Backbone.View);j=(function(D){y(C,D);function C(){a=C.__super__.constructor.apply(this,arguments);return a}C.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};C.prototype.template=function(){return Handlebars.templates.signature};C.prototype.switchToDescription=function(E){if(E!=null){E.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};C.prototype.switchToSnippet=function(E){if(E!=null){E.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};C.prototype.snippetToTextArea=function(E){var F;if(this.isParam){if(E!=null){E.preventDefault()}F=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(F.val())===""){return F.val(this.model.sampleJSON)}}};return C})(Backbone.View);l=(function(C){y(D,C);function D(){A=D.__super__.constructor.apply(this,arguments);return A}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.content_type};return D})(Backbone.View);o=(function(C){y(D,C);function D(){z=D.__super__.constructor.apply(this,arguments);return z}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.response_content_type};return D})(Backbone.View);n=(function(D){y(C,D);function C(){d=C.__super__.constructor.apply(this,arguments);return d}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};C.prototype.template=function(){return Handlebars.templates.parameter_content_type};return C})(Backbone.View);t=(function(D){y(C,D);function C(){b=C.__super__.constructor.apply(this,arguments);return b}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #apikey_button":"toggleApiKeyContainer","click #apply_api_key":"applyApiKey"};C.prototype.applyApiKey=function(){var E;window.authorizations.add(this.model.name,new ApiKeyAuthorization(this.model.name,$("#input_apiKey_entry").val(),this.model["in"]));window.swaggerUi.load();return E=$("#apikey_container").show()};C.prototype.toggleApiKeyContainer=function(){var E;if($("#apikey_container").length>0){E=$("#apikey_container").first();if(E.is(":visible")){return E.hide()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.apikey_button_view};return C})(Backbone.View);k=(function(D){y(C,D);function C(){B=C.__super__.constructor.apply(this,arguments);return B}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #basic_auth_button":"togglePasswordContainer","click #apply_basic_auth":"applyPassword"};C.prototype.applyPassword=function(){var F,E,G;console.log("applying password");G=$(".input_username").val();E=$(".input_password").val();window.authorizations.add(this.model.type,new PasswordAuthorization("basic",G,E));window.swaggerUi.load();return F=$("#basic_auth_container").hide()};C.prototype.togglePasswordContainer=function(){var E;if($("#basic_auth_container").length>0){E=$("#basic_auth_container").show();if(E.is(":visible")){return E.slideUp()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.basic_auth_button_view};return C})(Backbone.View)}).call(this);`) +var _www_swagger_ui_swagger_ui_min_js = []byte(`$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^` + "`" + `{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.apikey_button_view=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="
    apply api key
    \n
    \n
    \n
    ";if(c=d.keyName){c=c.call(k,{hash:{},data:i})}else{c=k.keyName;c=typeof c===f?c.apply(k):c}g+=h(c)+'
    \n \n \n
    \n
    \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.basic_auth_button_view=b(function(f,g,d,c,e){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,f.helpers);e=e||{};return'
    \n
    \n
    \n
    Username
    \n \n
    Password
    \n \n \n
    \n
    \n\n'})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",c,s,i="function",k=this.escapeExpression,q=this;function f(x,w){var t="",v,u;t+='\n
    '+k(((v=((v=x.info),v==null||v===false?v:v.title)),typeof v===i?v.apply(x):v))+'
    \n
    ';u=((v=((v=x.info),v==null||v===false?v:v.description)),typeof v===i?v.apply(x):v);if(u||u===0){t+=u}t+="
    \n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.license),{hash:{},inverse:q.noop,fn:q.program(6,p,w),data:w});if(u||u===0){t+=u}t+="\n ";return t}function d(w,v){var t="",u;t+='';return t}function r(w,v){var t="",u;t+="';return t}function p(w,v){var t="",u;t+="";return t}function o(w,v){var t="",u;t+='\n , api version: '+k(((u=((u=w.info),u==null||u===false?u:u.version)),typeof u===i?u.apply(w):u))+"\n ";return t}function e(w,v){var t="",u;t+='\n \n \n ';return t}j+="
    \n ";c=g["if"].call(n,n.info,{hash:{},inverse:q.noop,fn:q.program(1,f,l),data:l});if(c||c===0){j+=c}j+="\n
    \n
    \n
      \n\n
      \n
      \n
      \n

      [ base url: ";if(c=g.basePath){c=c.call(n,{hash:{},data:l})}else{c=n.basePath;c=typeof c===i?c.apply(n):c}j+=k(c)+"\n ";s=g["if"].call(n,((c=n.info),c==null||c===false?c:c.version),{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(s||s===0){j+=s}j+="]\n ";s=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(s||s===0){j+=s}j+="\n

      \n
      \n
      \n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(j,u,s,o,A){this.compilerInfo=[4,">= 1.0.0"];s=this.merge(s,j.helpers);A=A||{};var t="",k,f,e="function",d=this.escapeExpression,r=this,c=s.blockHelperMissing;function q(C,B){return"deprecated"}function p(C,B){return"\n

      Warning: Deprecated

      \n "}function n(E,D){var B="",C;B+="\n

      Implementation Notes

      \n

      ";if(C=s.description){C=C.call(E,{hash:{},data:D})}else{C=E.description;C=typeof C===e?C.apply(E):C}if(C||C===0){B+=C}B+="

      \n ";return B}function m(C,B){return'\n
      \n '}function i(E,D){var B="",C;B+='\n \n ";return B}function z(F,E){var B="",D,C;B+="\n
      "+d(((D=F.scope),typeof D===e?D.apply(F):D))+"
      \n ";return B}function y(C,B){return"
      "}function x(C,B){return'\n
      \n \n
      \n '}function w(C,B){return'\n

      Response Class

      \n

      \n
      \n
      \n '}function v(C,B){return'\n

      Parameters

      \n \n \n \n \n \n \n \n \n \n \n \n\n \n
      ParameterValueDescriptionParameter TypeData Type
      \n '}function l(C,B){return"\n
      \n

      Response Messages

      \n \n \n \n \n \n \n \n \n \n \n \n
      HTTP Status CodeReasonResponse Model
      \n "}function h(C,B){return"\n "}function g(C,B){return"\n
      \n \n \n \n
      \n "}t+="\n
        \n
      • \n \n \n
      • \n
      \n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n \n
      \n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n \n ";return v}function h(y,x){var v="",w;v+="\n \n
      \n
      \n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y["default"],{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n \n ";return v}function r(y,x){var v="",w;v+="\n \n ";return v}p+="";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C["default"],{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n \n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n \n ";return z}function u(C,B){var z="",A;z+="\n \n ";return z}s+="";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"\n\n \n\n";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="\n";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t["default"],{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t["default"],{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z["default"],{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
      \n
      \n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z["default"],{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(r,q){return" : "}function c(t,s){var q="",r;q+="
    • \n Raw\n
    • ";return q}i+="
      \n

      \n ';if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+" ";p={hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k};if(d=f.summary){d=d.call(m,p)}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(!f.summary){d=n.call(m,d,p)}if(d||d===0){i+=d}if(d=f.summary){d=d.call(m,{hash:{},data:k})}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n

      \n
      \n
      \n\n
      \n
      \n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
      \n\n
      \n
      ';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
      \n \n
      \n
      \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var t,k,l,u,x,q,n,m,p,o,j,r,v,s,i,d,b,B,h,g,f,e,c,a,A,z,w={}.hasOwnProperty,y=function(F,D){for(var C in D){if(w.call(D,C)){F[C]=D[C]}}function E(){this.constructor=F}E.prototype=D.prototype;F.prototype=new E();F.__super__=D.prototype;return F};v=(function(D){y(C,D);function C(){s=C.__super__.constructor.apply(this,arguments);return s}C.prototype.dom_id="swagger_ui";C.prototype.options=null;C.prototype.api=null;C.prototype.headerView=null;C.prototype.mainView=null;C.prototype.initialize=function(E){var F=this;if(E==null){E={}}if(E.dom_id!=null){this.dom_id=E.dom_id;delete E.dom_id}if($("#"+this.dom_id)==null){$("body").append('
      ')}this.options=E;this.options.success=function(){return F.render()};this.options.progress=function(G){return F.showMessage(G)};this.options.failure=function(G){if(F.api&&F.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");F.api=new SwaggerApi(F.options);return F.api.build()}else{return F.onLoadFailure(G)}};this.headerView=new u({el:$("#header")});return this.headerView.on("update-swagger-ui",function(G){return F.updateSwaggerUi(G)})};C.prototype.setOption=function(E,F){return this.options[E]=F};C.prototype.getOption=function(E){return this.options[E]};C.prototype.updateSwaggerUi=function(E){this.options.url=E.url;return this.load()};C.prototype.load=function(){var F,E;if((E=this.mainView)!=null){E.clear()}F=this.options.url;if(F.indexOf("http")!==0){F=this.buildUrl(window.location.href.toString(),F)}this.options.url=F;this.headerView.update(F);this.api=new SwaggerClient(this.options);return this.api.build()};C.prototype.collapseAll=function(){return Docs.collapseEndpointListForResource("")};C.prototype.listAll=function(){return Docs.collapseOperationsForResource("")};C.prototype.expandAll=function(){return Docs.expandOperationsForResource("")};C.prototype.render=function(){var E=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new x({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":this.expandAll();break;case"list":this.listAll()}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};C.prototype.buildUrl=function(G,E){var F,H;log("base is "+G);if(E.indexOf("/")===0){H=G.split("/");G=H[0]+"//"+H[2];return G+E}else{F=G.length;if(G.indexOf("?")>-1){F=Math.min(F,G.indexOf("?"))}if(G.indexOf("#")>-1){F=Math.min(F,G.indexOf("#"))}G=G.substring(0,F);if(G.indexOf("/",G.length-1)!==-1){return G+E}return G+"/"+E}};C.prototype.showMessage=function(E){if(E==null){E=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(E)};C.prototype.onLoadFailure=function(E){var F;if(E==null){E=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");F=$("#message-bar").html(E);if(this.options.onFailure!=null){this.options.onFailure(E)}return F};return C})(Backbone.Router);window.SwaggerUi=v;u=(function(D){y(C,D);function C(){i=C.__super__.constructor.apply(this,arguments);return i}C.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};C.prototype.initialize=function(){};C.prototype.showPetStore=function(E){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};C.prototype.showWordnikDev=function(E){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};C.prototype.showCustomOnKeyup=function(E){if(E.keyCode===13){return this.showCustom()}};C.prototype.showCustom=function(E){if(E!=null){E.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};C.prototype.update=function(F,G,E){if(E==null){E=false}$("#input_baseUrl").val(F);if(E){return this.trigger("update-swagger-ui",{url:F})}};return C})(Backbone.View);x=(function(C){var D;y(E,C);function E(){h=E.__super__.constructor.apply(this,arguments);return h}D={alpha:function(G,F){return G.path.localeCompare(F.path)},method:function(G,F){return G.method.localeCompare(F.method)}};E.prototype.initialize=function(J){var I,H,G,F,K,L;if(J==null){J={}}this.model.auths=[];L=this.model.securityDefinitions;for(H in L){K=L[H];I={name:H,type:K.type,value:K};this.model.auths.push(I)}if(this.model.info&&this.model.info.license&&typeof this.model.info.license==="string"){G=this.model.info.license;F=this.model.info.licenseUrl;this.model.info.license={};this.model.info.license.name=G;this.model.info.license.url=F}if(!this.model.info){this.model.info={}}if(!this.model.info.version){this.model.info.version=this.model.apiVersion}if(this.model.swaggerVersion==="2.0"){if("validatorUrl" in J.swaggerOptions){return this.model.validatorUrl=J.swaggerOptions.validatorUrl}else{if(this.model.url.indexOf("localhost")>0){return this.model.validatorUrl=null}else{return this.model.validatorUrl="http://online.swagger.io/validator"}}}};E.prototype.render=function(){var K,N,F,H,G,L,I,M,O,J;if(this.model.securityDefinitions){for(G in this.model.securityDefinitions){K=this.model.securityDefinitions[G];if(K.type==="apiKey"&&$("#apikey_button").length===0){N=new t({model:K}).render().el;$(".auth_main_container").append(N)}if(K.type==="basicAuth"&&$("#basic_auth_button").length===0){N=new k({model:K}).render().el;$(".auth_main_container").append(N)}}}$(this.el).html(Handlebars.templates.main(this.model));I={};F=0;J=this.model.apisArray;for(M=0,O=J.length;MF){O=F-G}if(OE){L=E-I}if(L")}this.model.oauth=null;if(this.model.authorizations){if(Array.isArray(this.model.authorizations)){Q=this.model.authorizations;for(ai=0,T=Q.length;ai0){H[M.name]=M.value}if(M.type==="file"){R=true}}I=K.find("textarea");for(P=0,J=I.length;P0){H[M.name]=M.value}}F=K.find("select");for(O=0,G=F.length;O0){H[M.name]=N}}E.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();E.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(R){return this.handleFileUpload(H,K)}else{return this.model["do"](H,E,this.showCompleteStatus,this.showErrorStatus,this)}}};C.prototype.success=function(E,F){return F.showCompleteStatus(E)};C.prototype.handleFileUpload=function(V,M){var Q,L,G,R,P,O,T,N,K,J,H,U,Y,X,W,I,F,E,Z,S=this;I=M.serializeArray();for(N=0,U=I.length;N0){V[R.name]=R.value}}Q=new FormData();T=0;F=this.model.parameters;for(K=0,Y=F.length;K
      ");$(".request_url pre",$(this.el)).text(this.invocationUrl);P={type:this.model.method,url:this.invocationUrl,headers:G,data:Q,dataType:"json",contentType:false,processData:false,error:function(ab,ac,aa){return S.showErrorStatus(S.wrap(ab),S)},success:function(aa){return S.showResponse(aa,S)},complete:function(aa){return S.showCompleteStatus(S.wrap(aa),S)}};if(window.authorizations){window.authorizations.apply(P)}if(T===0){P.data.append("fake","true")}jQuery.ajax(P);return false};C.prototype.wrap=function(I){var G,J,L,F,K,H,E;L={};J=I.getAllResponseHeaders().split("\r");for(H=0,E=J.length;H0){return G}else{return null}}};C.prototype.hideResponse=function(E){if(E!=null){E.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};C.prototype.showResponse=function(E){var F;F=JSON.stringify(E,null,"\t").replace(/\n/g,"
      ");return $(".response_body",$(this.el)).html(escape(F))};C.prototype.showErrorStatus=function(F,E){return E.showStatus(F)};C.prototype.showCompleteStatus=function(F,E){return E.showStatus(F)};C.prototype.formatXml=function(L){var H,K,F,M,R,N,G,E,P,Q,J,I,O;E=/(>)(<)(\/*)/g;Q=/[ ]*(.*)[ ]+\n/g;H=/(<.+>)(.+\n)/g;L=L.replace(E,"$1\n$2$3").replace(Q,"$1\n").replace(H,"$1\n$2");G=0;K="";R=L.split("\n");F=0;M="other";P={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};J=function(X){var T,S,V,Z,W,U,Y;U={single:Boolean(X.match(/<.+\/>/)),closing:Boolean(X.match(/<\/.+>/)),opening:Boolean(X.match(/<[^!?].*>/))};W=((function(){var aa;aa=[];for(V in U){Y=U[V];if(Y){aa.push(V)}}return aa})())[0];W=W===void 0?"other":W;T=M+"->"+W;M=W;Z="";F+=P[T];Z=((function(){var ab,ac,aa;aa=[];for(S=ab=0,ac=F;0<=ac?abac;S=0<=ac?++ab:--ab){aa.push(" ")}return aa})()).join("");if(T==="opening->closing"){return K=K.substr(0,K.length-1)+X+"\n"}else{return K+=Z+X+"\n"}};for(I=0,O=R.length;I").text("no content");I=$('
      ').append(G)}else{if(P==="application/json"||/\+json$/.test(P)){Q=null;try{Q=JSON.stringify(JSON.parse(N),null,"  ")}catch(O){M=O;Q="can't parse JSON.  Raw result:\n\n"+N}G=$("").text(Q);I=$('
      ').append(G)}else{if(P==="application/xml"||/\+xml$/.test(P)){G=$("").text(this.formatXml(N));I=$('
      ').append(G)}else{if(P==="text/html"){G=$("").html(_.escape(N));I=$('
      ').append(G)}else{if(/^image\//.test(P)){I=$("").attr("src",F)}else{G=$("").text(N);I=$('
      ').append(G)}}}}}L=I;$(".request_url",$(this.el)).html("
      ");$(".request_url pre",$(this.el)).text(F);$(".response_code",$(this.el)).html("
      "+J.status+"
      ");$(".response_body",$(this.el)).html(L);$(".response_headers",$(this.el)).html("
      "+_.escape(JSON.stringify(J.headers,null,"  ")).replace(/\n/g,"
      ")+"
      ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();K=$(".response_body",$(this.el))[0];E=this.options.swaggerOptions;if(E.highlightSizeThreshold&&J.data.length>E.highlightSizeThreshold){return K}else{return hljs.highlightBlock(K)}};C.prototype.toggleOperationContent=function(){var E;E=$("#"+Docs.escapeName(this.model.parentId+"_"+this.model.nickname+"_content"));if(E.is(":visible")){return Docs.collapseOperation(E)}else{return Docs.expandOperation(E)}};return C})(Backbone.View);r=(function(D){y(C,D);function C(){e=C.__super__.constructor.apply(this,arguments);return e}C.prototype.initialize=function(){};C.prototype.render=function(){var F,E,G;G=this.template();$(this.el).html(G(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){F={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};E=new j({model:F,tagName:"div"});$(".model-signature",this.$el).append(E.render().el)}else{$(".model-signature",this.$el).html("")}return this};C.prototype.template=function(){return Handlebars.templates.status_code};return C})(Backbone.View);m=(function(D){y(C,D);function C(){c=C.__super__.constructor.apply(this,arguments);return c}C.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(F,E){if(F.type.toLowerCase()==="array"||F.allowMultiple){return E.fn(this)}else{return E.inverse(this)}})};C.prototype.render=function(){var E,F,I,G,J,H,M,N,L,K;K=this.model.type||this.model.dataType;if(typeof K==="undefined"){H=this.model.schema;if(H&&H["$ref"]){G=H["$ref"];if(G.indexOf("#/definitions/")===0){K=G.substring("#/definitions/".length)}else{K=G}}}this.model.type=K;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(K&&K.toLowerCase()==="file"){this.model.isFile=true}this.model["default"]=this.model["default"]||this.model.defaultValue;if(this.model.allowableValues){this.model.isList=true}L=this.template();$(this.el).html(L(this.model));M={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){N=new j({model:M,tagName:"div"});$(".model-signature",$(this.el)).append(N.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}F=false;if(this.model.isBody){F=true}E={isParam:F};E.consumes=this.model.consumes;if(F){I=new n({model:E});$(".parameter-content-type",$(this.el)).append(I.render().el)}else{J=new o({model:E});$(".response-content-type",$(this.el)).append(J.render().el)}return this};C.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return C})(Backbone.View);j=(function(D){y(C,D);function C(){a=C.__super__.constructor.apply(this,arguments);return a}C.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};C.prototype.template=function(){return Handlebars.templates.signature};C.prototype.switchToDescription=function(E){if(E!=null){E.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};C.prototype.switchToSnippet=function(E){if(E!=null){E.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};C.prototype.snippetToTextArea=function(E){var F;if(this.isParam){if(E!=null){E.preventDefault()}F=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(F.val())===""){return F.val(this.model.sampleJSON)}}};return C})(Backbone.View);l=(function(C){y(D,C);function D(){A=D.__super__.constructor.apply(this,arguments);return A}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.content_type};return D})(Backbone.View);o=(function(C){y(D,C);function D(){z=D.__super__.constructor.apply(this,arguments);return z}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.response_content_type};return D})(Backbone.View);n=(function(D){y(C,D);function C(){d=C.__super__.constructor.apply(this,arguments);return d}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};C.prototype.template=function(){return Handlebars.templates.parameter_content_type};return C})(Backbone.View);t=(function(D){y(C,D);function C(){b=C.__super__.constructor.apply(this,arguments);return b}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #apikey_button":"toggleApiKeyContainer","click #apply_api_key":"applyApiKey"};C.prototype.applyApiKey=function(){var E;window.authorizations.add(this.model.name,new ApiKeyAuthorization(this.model.name,$("#input_apiKey_entry").val(),this.model["in"]));window.swaggerUi.load();return E=$("#apikey_container").show()};C.prototype.toggleApiKeyContainer=function(){var E;if($("#apikey_container").length>0){E=$("#apikey_container").first();if(E.is(":visible")){return E.hide()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.apikey_button_view};return C})(Backbone.View);k=(function(D){y(C,D);function C(){B=C.__super__.constructor.apply(this,arguments);return B}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #basic_auth_button":"togglePasswordContainer","click #apply_basic_auth":"applyPassword"};C.prototype.applyPassword=function(){var F,E,G;console.log("applying password");G=$(".input_username").val();E=$(".input_password").val();window.authorizations.add(this.model.type,new PasswordAuthorization("basic",G,E));window.swaggerUi.load();return F=$("#basic_auth_container").hide()};C.prototype.togglePasswordContainer=function(){var E;if($("#basic_auth_container").length>0){E=$("#basic_auth_container").show();if(E.is(":visible")){return E.slideUp()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.basic_auth_button_view};return C})(Backbone.View)}).call(this);`) func www_swagger_ui_swagger_ui_min_js_bytes() ([]byte, error) { return _www_swagger_ui_swagger_ui_min_js, nil diff --git a/plugin/pkg/scheduler/factory/factory.go b/plugin/pkg/scheduler/factory/factory.go index d87a596e9cf..a7c18c9b01e 100644 --- a/plugin/pkg/scheduler/factory/factory.go +++ b/plugin/pkg/scheduler/factory/factory.go @@ -139,7 +139,7 @@ type listWatch struct { func (lw *listWatch) List() (runtime.Object, error) { return lw.client. Get(). - Path(lw.resource). + Resource(lw.resource). SelectorParam("fields", lw.fieldSelector). Do(). Get() @@ -148,8 +148,8 @@ func (lw *listWatch) List() (runtime.Object, error) { func (lw *listWatch) Watch(resourceVersion string) (watch.Interface, error) { return lw.client. Get(). - Path("watch"). - Path(lw.resource). + Prefix("watch"). + Resource(lw.resource). SelectorParam("fields", lw.fieldSelector). Param("resourceVersion", resourceVersion). Watch() @@ -195,7 +195,7 @@ func (factory *ConfigFactory) createMinionLW() *listWatch { // pollMinions lists all minions and returns an enumerator for cache.Poller. func (factory *ConfigFactory) pollMinions() (cache.Enumerator, error) { list := &api.NodeList{} - err := factory.Client.Get().Path("minions").Do().Into(list) + err := factory.Client.Get().Resource("minions").Do().Into(list) if err != nil { return nil, err } @@ -215,7 +215,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue backoff.wait(podID) // Get the pod again; it may have changed/been scheduled already. pod = &api.Pod{} - err := factory.Client.Get().Namespace(podNamespace).Path("pods").Path(podID).Do().Into(pod) + err := factory.Client.Get().Namespace(podNamespace).Resource("pods").Name(podID).Do().Into(pod) if err != nil { glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err) return @@ -288,7 +288,7 @@ type binder struct { func (b *binder) Bind(binding *api.Binding) error { glog.V(2).Infof("Attempting to bind %v to %v", binding.PodID, binding.Host) ctx := api.WithNamespace(api.NewContext(), binding.Namespace) - return b.Post().Namespace(api.Namespace(ctx)).Path("bindings").Body(binding).Do().Error() + return b.Post().Namespace(api.Namespace(ctx)).Resource("bindings").Body(binding).Do().Error() } type clock interface {