summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/coreos/etcd/client
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-03-04 23:46:13 +0100
committerWim <wim@42.be>2018-03-04 23:46:13 +0100
commit25a72113b122f984c904b24c4af23a1cba1eff45 (patch)
treef0fb7067d7c958d60ac964afa5b8d5fb79ebc339 /vendor/github.com/coreos/etcd/client
parent79c4ad5015bd2be47b32141c6d53f0d128bf865b (diff)
downloadmatterbridge-msglm-25a72113b122f984c904b24c4af23a1cba1eff45.tar.gz
matterbridge-msglm-25a72113b122f984c904b24c4af23a1cba1eff45.tar.bz2
matterbridge-msglm-25a72113b122f984c904b24c4af23a1cba1eff45.zip
Add vendor files for spf13/viper
Diffstat (limited to 'vendor/github.com/coreos/etcd/client')
-rw-r--r--vendor/github.com/coreos/etcd/client/LICENSE202
-rw-r--r--vendor/github.com/coreos/etcd/client/auth_role.go236
-rw-r--r--vendor/github.com/coreos/etcd/client/auth_user.go319
-rw-r--r--vendor/github.com/coreos/etcd/client/cancelreq.go18
-rw-r--r--vendor/github.com/coreos/etcd/client/client.go710
-rw-r--r--vendor/github.com/coreos/etcd/client/cluster_error.go37
-rw-r--r--vendor/github.com/coreos/etcd/client/curl.go70
-rw-r--r--vendor/github.com/coreos/etcd/client/discover.go40
-rw-r--r--vendor/github.com/coreos/etcd/client/doc.go73
-rw-r--r--vendor/github.com/coreos/etcd/client/integration/doc.go17
-rw-r--r--vendor/github.com/coreos/etcd/client/keys.generated.go5218
-rw-r--r--vendor/github.com/coreos/etcd/client/keys.go681
-rw-r--r--vendor/github.com/coreos/etcd/client/members.go303
-rw-r--r--vendor/github.com/coreos/etcd/client/util.go53
14 files changed, 7977 insertions, 0 deletions
diff --git a/vendor/github.com/coreos/etcd/client/LICENSE b/vendor/github.com/coreos/etcd/client/LICENSE
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/coreos/etcd/client/auth_role.go b/vendor/github.com/coreos/etcd/client/auth_role.go
new file mode 100644
index 00000000..b6ba7e15
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/auth_role.go
@@ -0,0 +1,236 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/url"
+)
+
+type Role struct {
+ Role string `json:"role"`
+ Permissions Permissions `json:"permissions"`
+ Grant *Permissions `json:"grant,omitempty"`
+ Revoke *Permissions `json:"revoke,omitempty"`
+}
+
+type Permissions struct {
+ KV rwPermission `json:"kv"`
+}
+
+type rwPermission struct {
+ Read []string `json:"read"`
+ Write []string `json:"write"`
+}
+
+type PermissionType int
+
+const (
+ ReadPermission PermissionType = iota
+ WritePermission
+ ReadWritePermission
+)
+
+// NewAuthRoleAPI constructs a new AuthRoleAPI that uses HTTP to
+// interact with etcd's role creation and modification features.
+func NewAuthRoleAPI(c Client) AuthRoleAPI {
+ return &httpAuthRoleAPI{
+ client: c,
+ }
+}
+
+type AuthRoleAPI interface {
+ // AddRole adds a role.
+ AddRole(ctx context.Context, role string) error
+
+ // RemoveRole removes a role.
+ RemoveRole(ctx context.Context, role string) error
+
+ // GetRole retrieves role details.
+ GetRole(ctx context.Context, role string) (*Role, error)
+
+ // GrantRoleKV grants a role some permission prefixes for the KV store.
+ GrantRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error)
+
+ // RevokeRoleKV revokes some permission prefixes for a role on the KV store.
+ RevokeRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error)
+
+ // ListRoles lists roles.
+ ListRoles(ctx context.Context) ([]string, error)
+}
+
+type httpAuthRoleAPI struct {
+ client httpClient
+}
+
+type authRoleAPIAction struct {
+ verb string
+ name string
+ role *Role
+}
+
+type authRoleAPIList struct{}
+
+func (list *authRoleAPIList) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "roles", "")
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (l *authRoleAPIAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "roles", l.name)
+ if l.role == nil {
+ req, _ := http.NewRequest(l.verb, u.String(), nil)
+ return req
+ }
+ b, err := json.Marshal(l.role)
+ if err != nil {
+ panic(err)
+ }
+ body := bytes.NewReader(b)
+ req, _ := http.NewRequest(l.verb, u.String(), body)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (r *httpAuthRoleAPI) ListRoles(ctx context.Context) ([]string, error) {
+ resp, body, err := r.client.Do(ctx, &authRoleAPIList{})
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ return nil, err
+ }
+ var roleList struct {
+ Roles []Role `json:"roles"`
+ }
+ if err = json.Unmarshal(body, &roleList); err != nil {
+ return nil, err
+ }
+ ret := make([]string, 0, len(roleList.Roles))
+ for _, r := range roleList.Roles {
+ ret = append(ret, r.Role)
+ }
+ return ret, nil
+}
+
+func (r *httpAuthRoleAPI) AddRole(ctx context.Context, rolename string) error {
+ role := &Role{
+ Role: rolename,
+ }
+ return r.addRemoveRole(ctx, &authRoleAPIAction{
+ verb: "PUT",
+ name: rolename,
+ role: role,
+ })
+}
+
+func (r *httpAuthRoleAPI) RemoveRole(ctx context.Context, rolename string) error {
+ return r.addRemoveRole(ctx, &authRoleAPIAction{
+ verb: "DELETE",
+ name: rolename,
+ })
+}
+
+func (r *httpAuthRoleAPI) addRemoveRole(ctx context.Context, req *authRoleAPIAction) error {
+ resp, body, err := r.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+ if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
+ var sec authError
+ err := json.Unmarshal(body, &sec)
+ if err != nil {
+ return err
+ }
+ return sec
+ }
+ return nil
+}
+
+func (r *httpAuthRoleAPI) GetRole(ctx context.Context, rolename string) (*Role, error) {
+ return r.modRole(ctx, &authRoleAPIAction{
+ verb: "GET",
+ name: rolename,
+ })
+}
+
+func buildRWPermission(prefixes []string, permType PermissionType) rwPermission {
+ var out rwPermission
+ switch permType {
+ case ReadPermission:
+ out.Read = prefixes
+ case WritePermission:
+ out.Write = prefixes
+ case ReadWritePermission:
+ out.Read = prefixes
+ out.Write = prefixes
+ }
+ return out
+}
+
+func (r *httpAuthRoleAPI) GrantRoleKV(ctx context.Context, rolename string, prefixes []string, permType PermissionType) (*Role, error) {
+ rwp := buildRWPermission(prefixes, permType)
+ role := &Role{
+ Role: rolename,
+ Grant: &Permissions{
+ KV: rwp,
+ },
+ }
+ return r.modRole(ctx, &authRoleAPIAction{
+ verb: "PUT",
+ name: rolename,
+ role: role,
+ })
+}
+
+func (r *httpAuthRoleAPI) RevokeRoleKV(ctx context.Context, rolename string, prefixes []string, permType PermissionType) (*Role, error) {
+ rwp := buildRWPermission(prefixes, permType)
+ role := &Role{
+ Role: rolename,
+ Revoke: &Permissions{
+ KV: rwp,
+ },
+ }
+ return r.modRole(ctx, &authRoleAPIAction{
+ verb: "PUT",
+ name: rolename,
+ role: role,
+ })
+}
+
+func (r *httpAuthRoleAPI) modRole(ctx context.Context, req *authRoleAPIAction) (*Role, error) {
+ resp, body, err := r.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return nil, err
+ }
+ return nil, sec
+ }
+ var role Role
+ if err = json.Unmarshal(body, &role); err != nil {
+ return nil, err
+ }
+ return &role, nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/auth_user.go b/vendor/github.com/coreos/etcd/client/auth_user.go
new file mode 100644
index 00000000..8e7e2efe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/auth_user.go
@@ -0,0 +1,319 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/url"
+ "path"
+)
+
+var (
+ defaultV2AuthPrefix = "/v2/auth"
+)
+
+type User struct {
+ User string `json:"user"`
+ Password string `json:"password,omitempty"`
+ Roles []string `json:"roles"`
+ Grant []string `json:"grant,omitempty"`
+ Revoke []string `json:"revoke,omitempty"`
+}
+
+// userListEntry is the user representation given by the server for ListUsers
+type userListEntry struct {
+ User string `json:"user"`
+ Roles []Role `json:"roles"`
+}
+
+type UserRoles struct {
+ User string `json:"user"`
+ Roles []Role `json:"roles"`
+}
+
+func v2AuthURL(ep url.URL, action string, name string) *url.URL {
+ if name != "" {
+ ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action, name)
+ return &ep
+ }
+ ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action)
+ return &ep
+}
+
+// NewAuthAPI constructs a new AuthAPI that uses HTTP to
+// interact with etcd's general auth features.
+func NewAuthAPI(c Client) AuthAPI {
+ return &httpAuthAPI{
+ client: c,
+ }
+}
+
+type AuthAPI interface {
+ // Enable auth.
+ Enable(ctx context.Context) error
+
+ // Disable auth.
+ Disable(ctx context.Context) error
+}
+
+type httpAuthAPI struct {
+ client httpClient
+}
+
+func (s *httpAuthAPI) Enable(ctx context.Context) error {
+ return s.enableDisable(ctx, &authAPIAction{"PUT"})
+}
+
+func (s *httpAuthAPI) Disable(ctx context.Context) error {
+ return s.enableDisable(ctx, &authAPIAction{"DELETE"})
+}
+
+func (s *httpAuthAPI) enableDisable(ctx context.Context, req httpAction) error {
+ resp, body, err := s.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return err
+ }
+ return sec
+ }
+ return nil
+}
+
+type authAPIAction struct {
+ verb string
+}
+
+func (l *authAPIAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "enable", "")
+ req, _ := http.NewRequest(l.verb, u.String(), nil)
+ return req
+}
+
+type authError struct {
+ Message string `json:"message"`
+ Code int `json:"-"`
+}
+
+func (e authError) Error() string {
+ return e.Message
+}
+
+// NewAuthUserAPI constructs a new AuthUserAPI that uses HTTP to
+// interact with etcd's user creation and modification features.
+func NewAuthUserAPI(c Client) AuthUserAPI {
+ return &httpAuthUserAPI{
+ client: c,
+ }
+}
+
+type AuthUserAPI interface {
+ // AddUser adds a user.
+ AddUser(ctx context.Context, username string, password string) error
+
+ // RemoveUser removes a user.
+ RemoveUser(ctx context.Context, username string) error
+
+ // GetUser retrieves user details.
+ GetUser(ctx context.Context, username string) (*User, error)
+
+ // GrantUser grants a user some permission roles.
+ GrantUser(ctx context.Context, username string, roles []string) (*User, error)
+
+ // RevokeUser revokes some permission roles from a user.
+ RevokeUser(ctx context.Context, username string, roles []string) (*User, error)
+
+ // ChangePassword changes the user's password.
+ ChangePassword(ctx context.Context, username string, password string) (*User, error)
+
+ // ListUsers lists the users.
+ ListUsers(ctx context.Context) ([]string, error)
+}
+
+type httpAuthUserAPI struct {
+ client httpClient
+}
+
+type authUserAPIAction struct {
+ verb string
+ username string
+ user *User
+}
+
+type authUserAPIList struct{}
+
+func (list *authUserAPIList) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "users", "")
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (l *authUserAPIAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "users", l.username)
+ if l.user == nil {
+ req, _ := http.NewRequest(l.verb, u.String(), nil)
+ return req
+ }
+ b, err := json.Marshal(l.user)
+ if err != nil {
+ panic(err)
+ }
+ body := bytes.NewReader(b)
+ req, _ := http.NewRequest(l.verb, u.String(), body)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) {
+ resp, body, err := u.client.Do(ctx, &authUserAPIList{})
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return nil, err
+ }
+ return nil, sec
+ }
+
+ var userList struct {
+ Users []userListEntry `json:"users"`
+ }
+
+ if err = json.Unmarshal(body, &userList); err != nil {
+ return nil, err
+ }
+
+ ret := make([]string, 0, len(userList.Users))
+ for _, u := range userList.Users {
+ ret = append(ret, u.User)
+ }
+ return ret, nil
+}
+
+func (u *httpAuthUserAPI) AddUser(ctx context.Context, username string, password string) error {
+ user := &User{
+ User: username,
+ Password: password,
+ }
+ return u.addRemoveUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) RemoveUser(ctx context.Context, username string) error {
+ return u.addRemoveUser(ctx, &authUserAPIAction{
+ verb: "DELETE",
+ username: username,
+ })
+}
+
+func (u *httpAuthUserAPI) addRemoveUser(ctx context.Context, req *authUserAPIAction) error {
+ resp, body, err := u.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return err
+ }
+ return sec
+ }
+ return nil
+}
+
+func (u *httpAuthUserAPI) GetUser(ctx context.Context, username string) (*User, error) {
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "GET",
+ username: username,
+ })
+}
+
+func (u *httpAuthUserAPI) GrantUser(ctx context.Context, username string, roles []string) (*User, error) {
+ user := &User{
+ User: username,
+ Grant: roles,
+ }
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) RevokeUser(ctx context.Context, username string, roles []string) (*User, error) {
+ user := &User{
+ User: username,
+ Revoke: roles,
+ }
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) ChangePassword(ctx context.Context, username string, password string) (*User, error) {
+ user := &User{
+ User: username,
+ Password: password,
+ }
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) modUser(ctx context.Context, req *authUserAPIAction) (*User, error) {
+ resp, body, err := u.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return nil, err
+ }
+ return nil, sec
+ }
+ var user User
+ if err = json.Unmarshal(body, &user); err != nil {
+ var userR UserRoles
+ if urerr := json.Unmarshal(body, &userR); urerr != nil {
+ return nil, err
+ }
+ user.User = userR.User
+ for _, r := range userR.Roles {
+ user.Roles = append(user.Roles, r.Role)
+ }
+ }
+ return &user, nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/cancelreq.go b/vendor/github.com/coreos/etcd/client/cancelreq.go
new file mode 100644
index 00000000..76d1f040
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/cancelreq.go
@@ -0,0 +1,18 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// borrowed from golang/net/context/ctxhttp/cancelreq.go
+
+package client
+
+import "net/http"
+
+func requestCanceler(tr CancelableTransport, req *http.Request) func() {
+ ch := make(chan struct{})
+ req.Cancel = ch
+
+ return func() {
+ close(ch)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/client.go b/vendor/github.com/coreos/etcd/client/client.go
new file mode 100644
index 00000000..e6874505
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/client.go
@@ -0,0 +1,710 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "math/rand"
+ "net"
+ "net/http"
+ "net/url"
+ "sort"
+ "strconv"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/version"
+)
+
+var (
+ ErrNoEndpoints = errors.New("client: no endpoints available")
+ ErrTooManyRedirects = errors.New("client: too many redirects")
+ ErrClusterUnavailable = errors.New("client: etcd cluster is unavailable or misconfigured")
+ ErrNoLeaderEndpoint = errors.New("client: no leader endpoint available")
+ errTooManyRedirectChecks = errors.New("client: too many redirect checks")
+
+ // oneShotCtxValue is set on a context using WithValue(&oneShotValue) so
+ // that Do() will not retry a request
+ oneShotCtxValue interface{}
+)
+
+var DefaultRequestTimeout = 5 * time.Second
+
+var DefaultTransport CancelableTransport = &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ Dial: (&net.Dialer{
+ Timeout: 30 * time.Second,
+ KeepAlive: 30 * time.Second,
+ }).Dial,
+ TLSHandshakeTimeout: 10 * time.Second,
+}
+
+type EndpointSelectionMode int
+
+const (
+ // EndpointSelectionRandom is the default value of the 'SelectionMode'.
+ // As the name implies, the client object will pick a node from the members
+ // of the cluster in a random fashion. If the cluster has three members, A, B,
+ // and C, the client picks any node from its three members as its request
+ // destination.
+ EndpointSelectionRandom EndpointSelectionMode = iota
+
+ // If 'SelectionMode' is set to 'EndpointSelectionPrioritizeLeader',
+ // requests are sent directly to the cluster leader. This reduces
+ // forwarding roundtrips compared to making requests to etcd followers
+ // who then forward them to the cluster leader. In the event of a leader
+ // failure, however, clients configured this way cannot prioritize among
+ // the remaining etcd followers. Therefore, when a client sets 'SelectionMode'
+ // to 'EndpointSelectionPrioritizeLeader', it must use 'client.AutoSync()' to
+ // maintain its knowledge of current cluster state.
+ //
+ // This mode should be used with Client.AutoSync().
+ EndpointSelectionPrioritizeLeader
+)
+
+type Config struct {
+ // Endpoints defines a set of URLs (schemes, hosts and ports only)
+ // that can be used to communicate with a logical etcd cluster. For
+ // example, a three-node cluster could be provided like so:
+ //
+ // Endpoints: []string{
+ // "http://node1.example.com:2379",
+ // "http://node2.example.com:2379",
+ // "http://node3.example.com:2379",
+ // }
+ //
+ // If multiple endpoints are provided, the Client will attempt to
+ // use them all in the event that one or more of them are unusable.
+ //
+ // If Client.Sync is ever called, the Client may cache an alternate
+ // set of endpoints to continue operation.
+ Endpoints []string
+
+ // Transport is used by the Client to drive HTTP requests. If not
+ // provided, DefaultTransport will be used.
+ Transport CancelableTransport
+
+ // CheckRedirect specifies the policy for handling HTTP redirects.
+ // If CheckRedirect is not nil, the Client calls it before
+ // following an HTTP redirect. The sole argument is the number of
+ // requests that have already been made. If CheckRedirect returns
+ // an error, Client.Do will not make any further requests and return
+ // the error back it to the caller.
+ //
+ // If CheckRedirect is nil, the Client uses its default policy,
+ // which is to stop after 10 consecutive requests.
+ CheckRedirect CheckRedirectFunc
+
+ // Username specifies the user credential to add as an authorization header
+ Username string
+
+ // Password is the password for the specified user to add as an authorization header
+ // to the request.
+ Password string
+
+ // HeaderTimeoutPerRequest specifies the time limit to wait for response
+ // header in a single request made by the Client. The timeout includes
+ // connection time, any redirects, and header wait time.
+ //
+ // For non-watch GET request, server returns the response body immediately.
+ // For PUT/POST/DELETE request, server will attempt to commit request
+ // before responding, which is expected to take `100ms + 2 * RTT`.
+ // For watch request, server returns the header immediately to notify Client
+ // watch start. But if server is behind some kind of proxy, the response
+ // header may be cached at proxy, and Client cannot rely on this behavior.
+ //
+ // Especially, wait request will ignore this timeout.
+ //
+ // One API call may send multiple requests to different etcd servers until it
+ // succeeds. Use context of the API to specify the overall timeout.
+ //
+ // A HeaderTimeoutPerRequest of zero means no timeout.
+ HeaderTimeoutPerRequest time.Duration
+
+ // SelectionMode is an EndpointSelectionMode enum that specifies the
+ // policy for choosing the etcd cluster node to which requests are sent.
+ SelectionMode EndpointSelectionMode
+}
+
+func (cfg *Config) transport() CancelableTransport {
+ if cfg.Transport == nil {
+ return DefaultTransport
+ }
+ return cfg.Transport
+}
+
+func (cfg *Config) checkRedirect() CheckRedirectFunc {
+ if cfg.CheckRedirect == nil {
+ return DefaultCheckRedirect
+ }
+ return cfg.CheckRedirect
+}
+
+// CancelableTransport mimics net/http.Transport, but requires that
+// the object also support request cancellation.
+type CancelableTransport interface {
+ http.RoundTripper
+ CancelRequest(req *http.Request)
+}
+
+type CheckRedirectFunc func(via int) error
+
+// DefaultCheckRedirect follows up to 10 redirects, but no more.
+var DefaultCheckRedirect CheckRedirectFunc = func(via int) error {
+ if via > 10 {
+ return ErrTooManyRedirects
+ }
+ return nil
+}
+
+type Client interface {
+ // Sync updates the internal cache of the etcd cluster's membership.
+ Sync(context.Context) error
+
+ // AutoSync periodically calls Sync() every given interval.
+ // The recommended sync interval is 10 seconds to 1 minute, which does
+ // not bring too much overhead to server and makes client catch up the
+ // cluster change in time.
+ //
+ // The example to use it:
+ //
+ // for {
+ // err := client.AutoSync(ctx, 10*time.Second)
+ // if err == context.DeadlineExceeded || err == context.Canceled {
+ // break
+ // }
+ // log.Print(err)
+ // }
+ AutoSync(context.Context, time.Duration) error
+
+ // Endpoints returns a copy of the current set of API endpoints used
+ // by Client to resolve HTTP requests. If Sync has ever been called,
+ // this may differ from the initial Endpoints provided in the Config.
+ Endpoints() []string
+
+ // SetEndpoints sets the set of API endpoints used by Client to resolve
+ // HTTP requests. If the given endpoints are not valid, an error will be
+ // returned
+ SetEndpoints(eps []string) error
+
+ // GetVersion retrieves the current etcd server and cluster version
+ GetVersion(ctx context.Context) (*version.Versions, error)
+
+ httpClient
+}
+
+func New(cfg Config) (Client, error) {
+ c := &httpClusterClient{
+ clientFactory: newHTTPClientFactory(cfg.transport(), cfg.checkRedirect(), cfg.HeaderTimeoutPerRequest),
+ rand: rand.New(rand.NewSource(int64(time.Now().Nanosecond()))),
+ selectionMode: cfg.SelectionMode,
+ }
+ if cfg.Username != "" {
+ c.credentials = &credentials{
+ username: cfg.Username,
+ password: cfg.Password,
+ }
+ }
+ if err := c.SetEndpoints(cfg.Endpoints); err != nil {
+ return nil, err
+ }
+ return c, nil
+}
+
+type httpClient interface {
+ Do(context.Context, httpAction) (*http.Response, []byte, error)
+}
+
+func newHTTPClientFactory(tr CancelableTransport, cr CheckRedirectFunc, headerTimeout time.Duration) httpClientFactory {
+ return func(ep url.URL) httpClient {
+ return &redirectFollowingHTTPClient{
+ checkRedirect: cr,
+ client: &simpleHTTPClient{
+ transport: tr,
+ endpoint: ep,
+ headerTimeout: headerTimeout,
+ },
+ }
+ }
+}
+
+type credentials struct {
+ username string
+ password string
+}
+
+type httpClientFactory func(url.URL) httpClient
+
+type httpAction interface {
+ HTTPRequest(url.URL) *http.Request
+}
+
+type httpClusterClient struct {
+ clientFactory httpClientFactory
+ endpoints []url.URL
+ pinned int
+ credentials *credentials
+ sync.RWMutex
+ rand *rand.Rand
+ selectionMode EndpointSelectionMode
+}
+
+func (c *httpClusterClient) getLeaderEndpoint(ctx context.Context, eps []url.URL) (string, error) {
+ ceps := make([]url.URL, len(eps))
+ copy(ceps, eps)
+
+ // To perform a lookup on the new endpoint list without using the current
+ // client, we'll copy it
+ clientCopy := &httpClusterClient{
+ clientFactory: c.clientFactory,
+ credentials: c.credentials,
+ rand: c.rand,
+
+ pinned: 0,
+ endpoints: ceps,
+ }
+
+ mAPI := NewMembersAPI(clientCopy)
+ leader, err := mAPI.Leader(ctx)
+ if err != nil {
+ return "", err
+ }
+ if len(leader.ClientURLs) == 0 {
+ return "", ErrNoLeaderEndpoint
+ }
+
+ return leader.ClientURLs[0], nil // TODO: how to handle multiple client URLs?
+}
+
+func (c *httpClusterClient) parseEndpoints(eps []string) ([]url.URL, error) {
+ if len(eps) == 0 {
+ return []url.URL{}, ErrNoEndpoints
+ }
+
+ neps := make([]url.URL, len(eps))
+ for i, ep := range eps {
+ u, err := url.Parse(ep)
+ if err != nil {
+ return []url.URL{}, err
+ }
+ neps[i] = *u
+ }
+ return neps, nil
+}
+
+func (c *httpClusterClient) SetEndpoints(eps []string) error {
+ neps, err := c.parseEndpoints(eps)
+ if err != nil {
+ return err
+ }
+
+ c.Lock()
+ defer c.Unlock()
+
+ c.endpoints = shuffleEndpoints(c.rand, neps)
+ // We're not doing anything for PrioritizeLeader here. This is
+ // due to not having a context meaning we can't call getLeaderEndpoint
+ // However, if you're using PrioritizeLeader, you've already been told
+ // to regularly call sync, where we do have a ctx, and can figure the
+ // leader. PrioritizeLeader is also quite a loose guarantee, so deal
+ // with it
+ c.pinned = 0
+
+ return nil
+}
+
+func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+ action := act
+ c.RLock()
+ leps := len(c.endpoints)
+ eps := make([]url.URL, leps)
+ n := copy(eps, c.endpoints)
+ pinned := c.pinned
+
+ if c.credentials != nil {
+ action = &authedAction{
+ act: act,
+ credentials: *c.credentials,
+ }
+ }
+ c.RUnlock()
+
+ if leps == 0 {
+ return nil, nil, ErrNoEndpoints
+ }
+
+ if leps != n {
+ return nil, nil, errors.New("unable to pick endpoint: copy failed")
+ }
+
+ var resp *http.Response
+ var body []byte
+ var err error
+ cerr := &ClusterError{}
+ isOneShot := ctx.Value(&oneShotCtxValue) != nil
+
+ for i := pinned; i < leps+pinned; i++ {
+ k := i % leps
+ hc := c.clientFactory(eps[k])
+ resp, body, err = hc.Do(ctx, action)
+ if err != nil {
+ cerr.Errors = append(cerr.Errors, err)
+ if err == ctx.Err() {
+ return nil, nil, ctx.Err()
+ }
+ if err == context.Canceled || err == context.DeadlineExceeded {
+ return nil, nil, err
+ }
+ } else if resp.StatusCode/100 == 5 {
+ switch resp.StatusCode {
+ case http.StatusInternalServerError, http.StatusServiceUnavailable:
+ // TODO: make sure this is a no leader response
+ cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s has no leader", eps[k].String()))
+ default:
+ cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s returns server error [%s]", eps[k].String(), http.StatusText(resp.StatusCode)))
+ }
+ err = cerr.Errors[0]
+ }
+ if err != nil {
+ if !isOneShot {
+ continue
+ }
+ c.Lock()
+ c.pinned = (k + 1) % leps
+ c.Unlock()
+ return nil, nil, err
+ }
+ if k != pinned {
+ c.Lock()
+ c.pinned = k
+ c.Unlock()
+ }
+ return resp, body, nil
+ }
+
+ return nil, nil, cerr
+}
+
+func (c *httpClusterClient) Endpoints() []string {
+ c.RLock()
+ defer c.RUnlock()
+
+ eps := make([]string, len(c.endpoints))
+ for i, ep := range c.endpoints {
+ eps[i] = ep.String()
+ }
+
+ return eps
+}
+
+func (c *httpClusterClient) Sync(ctx context.Context) error {
+ mAPI := NewMembersAPI(c)
+ ms, err := mAPI.List(ctx)
+ if err != nil {
+ return err
+ }
+
+ var eps []string
+ for _, m := range ms {
+ eps = append(eps, m.ClientURLs...)
+ }
+
+ neps, err := c.parseEndpoints(eps)
+ if err != nil {
+ return err
+ }
+
+ npin := 0
+
+ switch c.selectionMode {
+ case EndpointSelectionRandom:
+ c.RLock()
+ eq := endpointsEqual(c.endpoints, neps)
+ c.RUnlock()
+
+ if eq {
+ return nil
+ }
+ // When items in the endpoint list changes, we choose a new pin
+ neps = shuffleEndpoints(c.rand, neps)
+ case EndpointSelectionPrioritizeLeader:
+ nle, err := c.getLeaderEndpoint(ctx, neps)
+ if err != nil {
+ return ErrNoLeaderEndpoint
+ }
+
+ for i, n := range neps {
+ if n.String() == nle {
+ npin = i
+ break
+ }
+ }
+ default:
+ return fmt.Errorf("invalid endpoint selection mode: %d", c.selectionMode)
+ }
+
+ c.Lock()
+ defer c.Unlock()
+ c.endpoints = neps
+ c.pinned = npin
+
+ return nil
+}
+
+func (c *httpClusterClient) AutoSync(ctx context.Context, interval time.Duration) error {
+ ticker := time.NewTicker(interval)
+ defer ticker.Stop()
+ for {
+ err := c.Sync(ctx)
+ if err != nil {
+ return err
+ }
+ select {
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-ticker.C:
+ }
+ }
+}
+
+func (c *httpClusterClient) GetVersion(ctx context.Context) (*version.Versions, error) {
+ act := &getAction{Prefix: "/version"}
+
+ resp, body, err := c.Do(ctx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ switch resp.StatusCode {
+ case http.StatusOK:
+ if len(body) == 0 {
+ return nil, ErrEmptyBody
+ }
+ var vresp version.Versions
+ if err := json.Unmarshal(body, &vresp); err != nil {
+ return nil, ErrInvalidJSON
+ }
+ return &vresp, nil
+ default:
+ var etcdErr Error
+ if err := json.Unmarshal(body, &etcdErr); err != nil {
+ return nil, ErrInvalidJSON
+ }
+ return nil, etcdErr
+ }
+}
+
+type roundTripResponse struct {
+ resp *http.Response
+ err error
+}
+
+type simpleHTTPClient struct {
+ transport CancelableTransport
+ endpoint url.URL
+ headerTimeout time.Duration
+}
+
+func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+ req := act.HTTPRequest(c.endpoint)
+
+ if err := printcURL(req); err != nil {
+ return nil, nil, err
+ }
+
+ isWait := false
+ if req != nil && req.URL != nil {
+ ws := req.URL.Query().Get("wait")
+ if len(ws) != 0 {
+ var err error
+ isWait, err = strconv.ParseBool(ws)
+ if err != nil {
+ return nil, nil, fmt.Errorf("wrong wait value %s (%v for %+v)", ws, err, req)
+ }
+ }
+ }
+
+ var hctx context.Context
+ var hcancel context.CancelFunc
+ if !isWait && c.headerTimeout > 0 {
+ hctx, hcancel = context.WithTimeout(ctx, c.headerTimeout)
+ } else {
+ hctx, hcancel = context.WithCancel(ctx)
+ }
+ defer hcancel()
+
+ reqcancel := requestCanceler(c.transport, req)
+
+ rtchan := make(chan roundTripResponse, 1)
+ go func() {
+ resp, err := c.transport.RoundTrip(req)
+ rtchan <- roundTripResponse{resp: resp, err: err}
+ close(rtchan)
+ }()
+
+ var resp *http.Response
+ var err error
+
+ select {
+ case rtresp := <-rtchan:
+ resp, err = rtresp.resp, rtresp.err
+ case <-hctx.Done():
+ // cancel and wait for request to actually exit before continuing
+ reqcancel()
+ rtresp := <-rtchan
+ resp = rtresp.resp
+ switch {
+ case ctx.Err() != nil:
+ err = ctx.Err()
+ case hctx.Err() != nil:
+ err = fmt.Errorf("client: endpoint %s exceeded header timeout", c.endpoint.String())
+ default:
+ panic("failed to get error from context")
+ }
+ }
+
+ // always check for resp nil-ness to deal with possible
+ // race conditions between channels above
+ defer func() {
+ if resp != nil {
+ resp.Body.Close()
+ }
+ }()
+
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var body []byte
+ done := make(chan struct{})
+ go func() {
+ body, err = ioutil.ReadAll(resp.Body)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-ctx.Done():
+ resp.Body.Close()
+ <-done
+ return nil, nil, ctx.Err()
+ case <-done:
+ }
+
+ return resp, body, err
+}
+
+type authedAction struct {
+ act httpAction
+ credentials credentials
+}
+
+func (a *authedAction) HTTPRequest(url url.URL) *http.Request {
+ r := a.act.HTTPRequest(url)
+ r.SetBasicAuth(a.credentials.username, a.credentials.password)
+ return r
+}
+
+type redirectFollowingHTTPClient struct {
+ client httpClient
+ checkRedirect CheckRedirectFunc
+}
+
+func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+ next := act
+ for i := 0; i < 100; i++ {
+ if i > 0 {
+ if err := r.checkRedirect(i); err != nil {
+ return nil, nil, err
+ }
+ }
+ resp, body, err := r.client.Do(ctx, next)
+ if err != nil {
+ return nil, nil, err
+ }
+ if resp.StatusCode/100 == 3 {
+ hdr := resp.Header.Get("Location")
+ if hdr == "" {
+ return nil, nil, fmt.Errorf("Location header not set")
+ }
+ loc, err := url.Parse(hdr)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr)
+ }
+ next = &redirectedHTTPAction{
+ action: act,
+ location: *loc,
+ }
+ continue
+ }
+ return resp, body, nil
+ }
+
+ return nil, nil, errTooManyRedirectChecks
+}
+
+type redirectedHTTPAction struct {
+ action httpAction
+ location url.URL
+}
+
+func (r *redirectedHTTPAction) HTTPRequest(ep url.URL) *http.Request {
+ orig := r.action.HTTPRequest(ep)
+ orig.URL = &r.location
+ return orig
+}
+
+func shuffleEndpoints(r *rand.Rand, eps []url.URL) []url.URL {
+ // copied from Go 1.9<= rand.Rand.Perm
+ n := len(eps)
+ p := make([]int, n)
+ for i := 0; i < n; i++ {
+ j := r.Intn(i + 1)
+ p[i] = p[j]
+ p[j] = i
+ }
+ neps := make([]url.URL, n)
+ for i, k := range p {
+ neps[i] = eps[k]
+ }
+ return neps
+}
+
+func endpointsEqual(left, right []url.URL) bool {
+ if len(left) != len(right) {
+ return false
+ }
+
+ sLeft := make([]string, len(left))
+ sRight := make([]string, len(right))
+ for i, l := range left {
+ sLeft[i] = l.String()
+ }
+ for i, r := range right {
+ sRight[i] = r.String()
+ }
+
+ sort.Strings(sLeft)
+ sort.Strings(sRight)
+ for i := range sLeft {
+ if sLeft[i] != sRight[i] {
+ return false
+ }
+ }
+ return true
+}
diff --git a/vendor/github.com/coreos/etcd/client/cluster_error.go b/vendor/github.com/coreos/etcd/client/cluster_error.go
new file mode 100644
index 00000000..34618cdb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/cluster_error.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import "fmt"
+
+type ClusterError struct {
+ Errors []error
+}
+
+func (ce *ClusterError) Error() string {
+ s := ErrClusterUnavailable.Error()
+ for i, e := range ce.Errors {
+ s += fmt.Sprintf("; error #%d: %s\n", i, e)
+ }
+ return s
+}
+
+func (ce *ClusterError) Detail() string {
+ s := ""
+ for i, e := range ce.Errors {
+ s += fmt.Sprintf("error #%d: %s\n", i, e)
+ }
+ return s
+}
diff --git a/vendor/github.com/coreos/etcd/client/curl.go b/vendor/github.com/coreos/etcd/client/curl.go
new file mode 100644
index 00000000..c8bc9fba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/curl.go
@@ -0,0 +1,70 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "os"
+)
+
+var (
+ cURLDebug = false
+)
+
+func EnablecURLDebug() {
+ cURLDebug = true
+}
+
+func DisablecURLDebug() {
+ cURLDebug = false
+}
+
+// printcURL prints the cURL equivalent request to stderr.
+// It returns an error if the body of the request cannot
+// be read.
+// The caller MUST cancel the request if there is an error.
+func printcURL(req *http.Request) error {
+ if !cURLDebug {
+ return nil
+ }
+ var (
+ command string
+ b []byte
+ err error
+ )
+
+ if req.URL != nil {
+ command = fmt.Sprintf("curl -X %s %s", req.Method, req.URL.String())
+ }
+
+ if req.Body != nil {
+ b, err = ioutil.ReadAll(req.Body)
+ if err != nil {
+ return err
+ }
+ command += fmt.Sprintf(" -d %q", string(b))
+ }
+
+ fmt.Fprintf(os.Stderr, "cURL Command: %s\n", command)
+
+ // reset body
+ body := bytes.NewBuffer(b)
+ req.Body = ioutil.NopCloser(body)
+
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/discover.go b/vendor/github.com/coreos/etcd/client/discover.go
new file mode 100644
index 00000000..442e35fe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/discover.go
@@ -0,0 +1,40 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "github.com/coreos/etcd/pkg/srv"
+)
+
+// Discoverer is an interface that wraps the Discover method.
+type Discoverer interface {
+ // Discover looks up the etcd servers for the domain.
+ Discover(domain string) ([]string, error)
+}
+
+type srvDiscover struct{}
+
+// NewSRVDiscover constructs a new Discoverer that uses the stdlib to lookup SRV records.
+func NewSRVDiscover() Discoverer {
+ return &srvDiscover{}
+}
+
+func (d *srvDiscover) Discover(domain string) ([]string, error) {
+ srvs, err := srv.GetClient("etcd-client", domain)
+ if err != nil {
+ return nil, err
+ }
+ return srvs.Endpoints, nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/doc.go b/vendor/github.com/coreos/etcd/client/doc.go
new file mode 100644
index 00000000..ad4eca4e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/doc.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/*
+Package client provides bindings for the etcd APIs.
+
+Create a Config and exchange it for a Client:
+
+ import (
+ "net/http"
+ "context"
+
+ "github.com/coreos/etcd/client"
+ )
+
+ cfg := client.Config{
+ Endpoints: []string{"http://127.0.0.1:2379"},
+ Transport: DefaultTransport,
+ }
+
+ c, err := client.New(cfg)
+ if err != nil {
+ // handle error
+ }
+
+Clients are safe for concurrent use by multiple goroutines.
+
+Create a KeysAPI using the Client, then use it to interact with etcd:
+
+ kAPI := client.NewKeysAPI(c)
+
+ // create a new key /foo with the value "bar"
+ _, err = kAPI.Create(context.Background(), "/foo", "bar")
+ if err != nil {
+ // handle error
+ }
+
+ // delete the newly created key only if the value is still "bar"
+ _, err = kAPI.Delete(context.Background(), "/foo", &DeleteOptions{PrevValue: "bar"})
+ if err != nil {
+ // handle error
+ }
+
+Use a custom context to set timeouts on your operations:
+
+ import "time"
+
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+
+ // set a new key, ignoring its previous state
+ _, err := kAPI.Set(ctx, "/ping", "pong", nil)
+ if err != nil {
+ if err == context.DeadlineExceeded {
+ // request took longer than 5s
+ } else {
+ // handle error
+ }
+ }
+
+*/
+package client
diff --git a/vendor/github.com/coreos/etcd/client/integration/doc.go b/vendor/github.com/coreos/etcd/client/integration/doc.go
new file mode 100644
index 00000000..e9c58d67
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/integration/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package integration implements tests built upon embedded etcd, focusing on
+// the correctness of the etcd v2 client.
+package integration
diff --git a/vendor/github.com/coreos/etcd/client/keys.generated.go b/vendor/github.com/coreos/etcd/client/keys.generated.go
new file mode 100644
index 00000000..237fdbe8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/keys.generated.go
@@ -0,0 +1,5218 @@
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED BY codecgen.
+// ************************************************************
+
+package client
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "runtime"
+ time "time"
+
+ codec1978 "github.com/ugorji/go/codec"
+)
+
+const (
+ // ----- content types ----
+ codecSelferC_UTF87612 = 1
+ codecSelferC_RAW7612 = 0
+ // ----- value types used ----
+ codecSelferValueTypeArray7612 = 10
+ codecSelferValueTypeMap7612 = 9
+ // ----- containerStateValues ----
+ codecSelfer_containerMapKey7612 = 2
+ codecSelfer_containerMapValue7612 = 3
+ codecSelfer_containerMapEnd7612 = 4
+ codecSelfer_containerArrayElem7612 = 6
+ codecSelfer_containerArrayEnd7612 = 7
+)
+
+var (
+ codecSelferBitsize7612 = uint8(reflect.TypeOf(uint(0)).Bits())
+ codecSelferOnlyMapOrArrayEncodeToStructErr7612 = errors.New(`only encoded map or array can be decoded into a struct`)
+)
+
+type codecSelfer7612 struct{}
+
+func init() {
+ if codec1978.GenVersion != 8 {
+ _, file, _, _ := runtime.Caller(0)
+ err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v",
+ 8, codec1978.GenVersion, file)
+ panic(err)
+ }
+ if false { // reference the types, but skip this branch at build/run time
+ var v0 time.Duration
+ _ = v0
+ }
+}
+
+func (x *Error) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(4)
+ } else {
+ r.WriteMapStart(4)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeInt(int64(x.Code))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("errorCode"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeInt(int64(x.Code))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Message))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("message"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Message))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Cause))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("cause"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Cause))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.Index))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("index"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.Index))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *Error) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *Error) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "errorCode":
+ if r.TryDecodeAsNil() {
+ x.Code = 0
+ } else {
+ yyv4 := &x.Code
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*int)(yyv4)) = int(r.DecodeInt(codecSelferBitsize7612))
+ }
+ }
+ case "message":
+ if r.TryDecodeAsNil() {
+ x.Message = ""
+ } else {
+ yyv6 := &x.Message
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*string)(yyv6)) = r.DecodeString()
+ }
+ }
+ case "cause":
+ if r.TryDecodeAsNil() {
+ x.Cause = ""
+ } else {
+ yyv8 := &x.Cause
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*string)(yyv8)) = r.DecodeString()
+ }
+ }
+ case "index":
+ if r.TryDecodeAsNil() {
+ x.Index = 0
+ } else {
+ yyv10 := &x.Index
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else {
+ *((*uint64)(yyv10)) = uint64(r.DecodeUint(64))
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *Error) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj12 int
+ var yyb12 bool
+ var yyhl12 bool = l >= 0
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Code = 0
+ } else {
+ yyv13 := &x.Code
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*int)(yyv13)) = int(r.DecodeInt(codecSelferBitsize7612))
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Message = ""
+ } else {
+ yyv15 := &x.Message
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*string)(yyv15)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Cause = ""
+ } else {
+ yyv17 := &x.Cause
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*string)(yyv17)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Index = 0
+ } else {
+ yyv19 := &x.Index
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else {
+ *((*uint64)(yyv19)) = uint64(r.DecodeUint(64))
+ }
+ }
+ for {
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj12-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x PrevExistType) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x))
+ }
+}
+
+func (x *PrevExistType) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ *((*string)(x)) = r.DecodeString()
+ }
+}
+
+func (x *WatcherOptions) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(2)
+ } else {
+ r.WriteMapStart(2)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.AfterIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("AfterIndex"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.AfterIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Recursive"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *WatcherOptions) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *WatcherOptions) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "AfterIndex":
+ if r.TryDecodeAsNil() {
+ x.AfterIndex = 0
+ } else {
+ yyv4 := &x.AfterIndex
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*uint64)(yyv4)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "Recursive":
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv6 := &x.Recursive
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*bool)(yyv6)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *WatcherOptions) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj8 int
+ var yyb8 bool
+ var yyhl8 bool = l >= 0
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.AfterIndex = 0
+ } else {
+ yyv9 := &x.AfterIndex
+ yym10 := z.DecBinary()
+ _ = yym10
+ if false {
+ } else {
+ *((*uint64)(yyv9)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv11 := &x.Recursive
+ yym12 := z.DecBinary()
+ _ = yym12
+ if false {
+ } else {
+ *((*bool)(yyv11)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj8-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *CreateInOrderOptions) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(1)
+ } else {
+ r.WriteMapStart(1)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("TTL"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *CreateInOrderOptions) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *CreateInOrderOptions) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "TTL":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv4 := &x.TTL
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv4) {
+ } else {
+ *((*int64)(yyv4)) = int64(r.DecodeInt(64))
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *CreateInOrderOptions) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj6 int
+ var yyb6 bool
+ var yyhl6 bool = l >= 0
+ yyj6++
+ if yyhl6 {
+ yyb6 = yyj6 > l
+ } else {
+ yyb6 = r.CheckBreak()
+ }
+ if yyb6 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv7 := &x.TTL
+ yym8 := z.DecBinary()
+ _ = yym8
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv7) {
+ } else {
+ *((*int64)(yyv7)) = int64(r.DecodeInt(64))
+ }
+ }
+ for {
+ yyj6++
+ if yyhl6 {
+ yyb6 = yyj6 > l
+ } else {
+ yyb6 = r.CheckBreak()
+ }
+ if yyb6 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj6-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *SetOptions) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(7)
+ } else {
+ r.WriteMapStart(7)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevValue"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevIndex"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ x.PrevExist.CodecEncodeSelf(e)
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevExist"))
+ r.WriteMapElemValue()
+ x.PrevExist.CodecEncodeSelf(e)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("TTL"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym16 := z.EncBinary()
+ _ = yym16
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Refresh))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Refresh"))
+ r.WriteMapElemValue()
+ yym17 := z.EncBinary()
+ _ = yym17
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Refresh))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym19 := z.EncBinary()
+ _ = yym19
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Dir"))
+ r.WriteMapElemValue()
+ yym20 := z.EncBinary()
+ _ = yym20
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym22 := z.EncBinary()
+ _ = yym22
+ if false {
+ } else {
+ r.EncodeBool(bool(x.NoValueOnSuccess))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("NoValueOnSuccess"))
+ r.WriteMapElemValue()
+ yym23 := z.EncBinary()
+ _ = yym23
+ if false {
+ } else {
+ r.EncodeBool(bool(x.NoValueOnSuccess))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *SetOptions) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *SetOptions) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "PrevValue":
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv4 := &x.PrevValue
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "PrevIndex":
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv6 := &x.PrevIndex
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*uint64)(yyv6)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "PrevExist":
+ if r.TryDecodeAsNil() {
+ x.PrevExist = ""
+ } else {
+ yyv8 := &x.PrevExist
+ yyv8.CodecDecodeSelf(d)
+ }
+ case "TTL":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv9 := &x.TTL
+ yym10 := z.DecBinary()
+ _ = yym10
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv9) {
+ } else {
+ *((*int64)(yyv9)) = int64(r.DecodeInt(64))
+ }
+ }
+ case "Refresh":
+ if r.TryDecodeAsNil() {
+ x.Refresh = false
+ } else {
+ yyv11 := &x.Refresh
+ yym12 := z.DecBinary()
+ _ = yym12
+ if false {
+ } else {
+ *((*bool)(yyv11)) = r.DecodeBool()
+ }
+ }
+ case "Dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv13 := &x.Dir
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*bool)(yyv13)) = r.DecodeBool()
+ }
+ }
+ case "NoValueOnSuccess":
+ if r.TryDecodeAsNil() {
+ x.NoValueOnSuccess = false
+ } else {
+ yyv15 := &x.NoValueOnSuccess
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*bool)(yyv15)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *SetOptions) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj17 int
+ var yyb17 bool
+ var yyhl17 bool = l >= 0
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv18 := &x.PrevValue
+ yym19 := z.DecBinary()
+ _ = yym19
+ if false {
+ } else {
+ *((*string)(yyv18)) = r.DecodeString()
+ }
+ }
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv20 := &x.PrevIndex
+ yym21 := z.DecBinary()
+ _ = yym21
+ if false {
+ } else {
+ *((*uint64)(yyv20)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevExist = ""
+ } else {
+ yyv22 := &x.PrevExist
+ yyv22.CodecDecodeSelf(d)
+ }
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv23 := &x.TTL
+ yym24 := z.DecBinary()
+ _ = yym24
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv23) {
+ } else {
+ *((*int64)(yyv23)) = int64(r.DecodeInt(64))
+ }
+ }
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Refresh = false
+ } else {
+ yyv25 := &x.Refresh
+ yym26 := z.DecBinary()
+ _ = yym26
+ if false {
+ } else {
+ *((*bool)(yyv25)) = r.DecodeBool()
+ }
+ }
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv27 := &x.Dir
+ yym28 := z.DecBinary()
+ _ = yym28
+ if false {
+ } else {
+ *((*bool)(yyv27)) = r.DecodeBool()
+ }
+ }
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.NoValueOnSuccess = false
+ } else {
+ yyv29 := &x.NoValueOnSuccess
+ yym30 := z.DecBinary()
+ _ = yym30
+ if false {
+ } else {
+ *((*bool)(yyv29)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj17++
+ if yyhl17 {
+ yyb17 = yyj17 > l
+ } else {
+ yyb17 = r.CheckBreak()
+ }
+ if yyb17 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj17-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *GetOptions) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(3)
+ } else {
+ r.WriteMapStart(3)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Recursive"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Sort))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Sort"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Sort))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Quorum))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Quorum"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Quorum))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *GetOptions) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *GetOptions) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "Recursive":
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv4 := &x.Recursive
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*bool)(yyv4)) = r.DecodeBool()
+ }
+ }
+ case "Sort":
+ if r.TryDecodeAsNil() {
+ x.Sort = false
+ } else {
+ yyv6 := &x.Sort
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*bool)(yyv6)) = r.DecodeBool()
+ }
+ }
+ case "Quorum":
+ if r.TryDecodeAsNil() {
+ x.Quorum = false
+ } else {
+ yyv8 := &x.Quorum
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*bool)(yyv8)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *GetOptions) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj10 int
+ var yyb10 bool
+ var yyhl10 bool = l >= 0
+ yyj10++
+ if yyhl10 {
+ yyb10 = yyj10 > l
+ } else {
+ yyb10 = r.CheckBreak()
+ }
+ if yyb10 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv11 := &x.Recursive
+ yym12 := z.DecBinary()
+ _ = yym12
+ if false {
+ } else {
+ *((*bool)(yyv11)) = r.DecodeBool()
+ }
+ }
+ yyj10++
+ if yyhl10 {
+ yyb10 = yyj10 > l
+ } else {
+ yyb10 = r.CheckBreak()
+ }
+ if yyb10 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Sort = false
+ } else {
+ yyv13 := &x.Sort
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*bool)(yyv13)) = r.DecodeBool()
+ }
+ }
+ yyj10++
+ if yyhl10 {
+ yyb10 = yyj10 > l
+ } else {
+ yyb10 = r.CheckBreak()
+ }
+ if yyb10 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Quorum = false
+ } else {
+ yyv15 := &x.Quorum
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*bool)(yyv15)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj10++
+ if yyhl10 {
+ yyb10 = yyj10 > l
+ } else {
+ yyb10 = r.CheckBreak()
+ }
+ if yyb10 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj10-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *DeleteOptions) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(4)
+ } else {
+ r.WriteMapStart(4)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevValue"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevIndex"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Recursive"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Dir"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *DeleteOptions) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *DeleteOptions) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "PrevValue":
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv4 := &x.PrevValue
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "PrevIndex":
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv6 := &x.PrevIndex
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*uint64)(yyv6)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "Recursive":
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv8 := &x.Recursive
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*bool)(yyv8)) = r.DecodeBool()
+ }
+ }
+ case "Dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv10 := &x.Dir
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else {
+ *((*bool)(yyv10)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *DeleteOptions) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj12 int
+ var yyb12 bool
+ var yyhl12 bool = l >= 0
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv13 := &x.PrevValue
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*string)(yyv13)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv15 := &x.PrevIndex
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*uint64)(yyv15)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv17 := &x.Recursive
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*bool)(yyv17)) = r.DecodeBool()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv19 := &x.Dir
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else {
+ *((*bool)(yyv19)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj12-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(3)
+ } else {
+ r.WriteMapStart(3)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Action))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("action"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Action))
+ }
+ }
+ var yyn6 bool
+ if x.Node == nil {
+ yyn6 = true
+ goto LABEL6
+ }
+ LABEL6:
+ if yyr2 || yy2arr2 {
+ if yyn6 {
+ r.WriteArrayElem()
+ r.EncodeNil()
+ } else {
+ r.WriteArrayElem()
+ if x.Node == nil {
+ r.EncodeNil()
+ } else {
+ x.Node.CodecEncodeSelf(e)
+ }
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("node"))
+ r.WriteMapElemValue()
+ if yyn6 {
+ r.EncodeNil()
+ } else {
+ if x.Node == nil {
+ r.EncodeNil()
+ } else {
+ x.Node.CodecEncodeSelf(e)
+ }
+ }
+ }
+ var yyn9 bool
+ if x.PrevNode == nil {
+ yyn9 = true
+ goto LABEL9
+ }
+ LABEL9:
+ if yyr2 || yy2arr2 {
+ if yyn9 {
+ r.WriteArrayElem()
+ r.EncodeNil()
+ } else {
+ r.WriteArrayElem()
+ if x.PrevNode == nil {
+ r.EncodeNil()
+ } else {
+ x.PrevNode.CodecEncodeSelf(e)
+ }
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("prevNode"))
+ r.WriteMapElemValue()
+ if yyn9 {
+ r.EncodeNil()
+ } else {
+ if x.PrevNode == nil {
+ r.EncodeNil()
+ } else {
+ x.PrevNode.CodecEncodeSelf(e)
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "action":
+ if r.TryDecodeAsNil() {
+ x.Action = ""
+ } else {
+ yyv4 := &x.Action
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "node":
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ if r.TryDecodeAsNil() {
+ if x.Node != nil {
+ x.Node = nil
+ }
+ } else {
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ x.Node.CodecDecodeSelf(d)
+ }
+ case "prevNode":
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ if r.TryDecodeAsNil() {
+ if x.PrevNode != nil {
+ x.PrevNode = nil
+ }
+ } else {
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ x.PrevNode.CodecDecodeSelf(d)
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj8 int
+ var yyb8 bool
+ var yyhl8 bool = l >= 0
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Action = ""
+ } else {
+ yyv9 := &x.Action
+ yym10 := z.DecBinary()
+ _ = yym10
+ if false {
+ } else {
+ *((*string)(yyv9)) = r.DecodeString()
+ }
+ }
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ if x.Node != nil {
+ x.Node = nil
+ }
+ } else {
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ x.Node.CodecDecodeSelf(d)
+ }
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ if x.PrevNode != nil {
+ x.PrevNode = nil
+ }
+ } else {
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ x.PrevNode.CodecDecodeSelf(d)
+ }
+ for {
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj8-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *Node) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ var yyq2 [8]bool
+ _ = yyq2
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ yyq2[1] = x.Dir != false
+ yyq2[6] = x.Expiration != nil
+ yyq2[7] = x.TTL != 0
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(8)
+ } else {
+ var yynn2 = 5
+ for _, b := range yyq2 {
+ if b {
+ yynn2++
+ }
+ }
+ r.WriteMapStart(yynn2)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("key"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ if yyq2[1] {
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.EncodeBool(false)
+ }
+ } else {
+ if yyq2[1] {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("dir"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Value))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("value"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Value))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ if x.Nodes == nil {
+ r.EncodeNil()
+ } else {
+ x.Nodes.CodecEncodeSelf(e)
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("nodes"))
+ r.WriteMapElemValue()
+ if x.Nodes == nil {
+ r.EncodeNil()
+ } else {
+ x.Nodes.CodecEncodeSelf(e)
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym16 := z.EncBinary()
+ _ = yym16
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.CreatedIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("createdIndex"))
+ r.WriteMapElemValue()
+ yym17 := z.EncBinary()
+ _ = yym17
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.CreatedIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym19 := z.EncBinary()
+ _ = yym19
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.ModifiedIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("modifiedIndex"))
+ r.WriteMapElemValue()
+ yym20 := z.EncBinary()
+ _ = yym20
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.ModifiedIndex))
+ }
+ }
+ var yyn21 bool
+ if x.Expiration == nil {
+ yyn21 = true
+ goto LABEL21
+ }
+ LABEL21:
+ if yyr2 || yy2arr2 {
+ if yyn21 {
+ r.WriteArrayElem()
+ r.EncodeNil()
+ } else {
+ r.WriteArrayElem()
+ if yyq2[6] {
+ if x.Expiration == nil {
+ r.EncodeNil()
+ } else {
+ yym22 := z.EncBinary()
+ _ = yym22
+ if false {
+ } else if yym23 := z.TimeRtidIfBinc(); yym23 != 0 {
+ r.EncodeBuiltin(yym23, x.Expiration)
+ } else if z.HasExtensions() && z.EncExt(x.Expiration) {
+ } else if yym22 {
+ z.EncBinaryMarshal(x.Expiration)
+ } else if !yym22 && z.IsJSONHandle() {
+ z.EncJSONMarshal(x.Expiration)
+ } else {
+ z.EncFallback(x.Expiration)
+ }
+ }
+ } else {
+ r.EncodeNil()
+ }
+ }
+ } else {
+ if yyq2[6] {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("expiration"))
+ r.WriteMapElemValue()
+ if yyn21 {
+ r.EncodeNil()
+ } else {
+ if x.Expiration == nil {
+ r.EncodeNil()
+ } else {
+ yym24 := z.EncBinary()
+ _ = yym24
+ if false {
+ } else if yym25 := z.TimeRtidIfBinc(); yym25 != 0 {
+ r.EncodeBuiltin(yym25, x.Expiration)
+ } else if z.HasExtensions() && z.EncExt(x.Expiration) {
+ } else if yym24 {
+ z.EncBinaryMarshal(x.Expiration)
+ } else if !yym24 && z.IsJSONHandle() {
+ z.EncJSONMarshal(x.Expiration)
+ } else {
+ z.EncFallback(x.Expiration)
+ }
+ }
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ if yyq2[7] {
+ yym27 := z.EncBinary()
+ _ = yym27
+ if false {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.EncodeInt(0)
+ }
+ } else {
+ if yyq2[7] {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("ttl"))
+ r.WriteMapElemValue()
+ yym28 := z.EncBinary()
+ _ = yym28
+ if false {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *Node) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv4 := &x.Key
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv6 := &x.Dir
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*bool)(yyv6)) = r.DecodeBool()
+ }
+ }
+ case "value":
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv8 := &x.Value
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*string)(yyv8)) = r.DecodeString()
+ }
+ }
+ case "nodes":
+ if r.TryDecodeAsNil() {
+ x.Nodes = nil
+ } else {
+ yyv10 := &x.Nodes
+ yyv10.CodecDecodeSelf(d)
+ }
+ case "createdIndex":
+ if r.TryDecodeAsNil() {
+ x.CreatedIndex = 0
+ } else {
+ yyv11 := &x.CreatedIndex
+ yym12 := z.DecBinary()
+ _ = yym12
+ if false {
+ } else {
+ *((*uint64)(yyv11)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "modifiedIndex":
+ if r.TryDecodeAsNil() {
+ x.ModifiedIndex = 0
+ } else {
+ yyv13 := &x.ModifiedIndex
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*uint64)(yyv13)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "expiration":
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ if r.TryDecodeAsNil() {
+ if x.Expiration != nil {
+ x.Expiration = nil
+ }
+ } else {
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else if yym17 := z.TimeRtidIfBinc(); yym17 != 0 {
+ r.DecodeBuiltin(yym17, x.Expiration)
+ } else if z.HasExtensions() && z.DecExt(x.Expiration) {
+ } else if yym16 {
+ z.DecBinaryUnmarshal(x.Expiration)
+ } else if !yym16 && z.IsJSONHandle() {
+ z.DecJSONUnmarshal(x.Expiration)
+ } else {
+ z.DecFallback(x.Expiration, false)
+ }
+ }
+ case "ttl":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv18 := &x.TTL
+ yym19 := z.DecBinary()
+ _ = yym19
+ if false {
+ } else {
+ *((*int64)(yyv18)) = int64(r.DecodeInt(64))
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *Node) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj20 int
+ var yyb20 bool
+ var yyhl20 bool = l >= 0
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv21 := &x.Key
+ yym22 := z.DecBinary()
+ _ = yym22
+ if false {
+ } else {
+ *((*string)(yyv21)) = r.DecodeString()
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv23 := &x.Dir
+ yym24 := z.DecBinary()
+ _ = yym24
+ if false {
+ } else {
+ *((*bool)(yyv23)) = r.DecodeBool()
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv25 := &x.Value
+ yym26 := z.DecBinary()
+ _ = yym26
+ if false {
+ } else {
+ *((*string)(yyv25)) = r.DecodeString()
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Nodes = nil
+ } else {
+ yyv27 := &x.Nodes
+ yyv27.CodecDecodeSelf(d)
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.CreatedIndex = 0
+ } else {
+ yyv28 := &x.CreatedIndex
+ yym29 := z.DecBinary()
+ _ = yym29
+ if false {
+ } else {
+ *((*uint64)(yyv28)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.ModifiedIndex = 0
+ } else {
+ yyv30 := &x.ModifiedIndex
+ yym31 := z.DecBinary()
+ _ = yym31
+ if false {
+ } else {
+ *((*uint64)(yyv30)) = uint64(r.DecodeUint(64))
+ }
+ }
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ if x.Expiration != nil {
+ x.Expiration = nil
+ }
+ } else {
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yym33 := z.DecBinary()
+ _ = yym33
+ if false {
+ } else if yym34 := z.TimeRtidIfBinc(); yym34 != 0 {
+ r.DecodeBuiltin(yym34, x.Expiration)
+ } else if z.HasExtensions() && z.DecExt(x.Expiration) {
+ } else if yym33 {
+ z.DecBinaryUnmarshal(x.Expiration)
+ } else if !yym33 && z.IsJSONHandle() {
+ z.DecJSONUnmarshal(x.Expiration)
+ } else {
+ z.DecFallback(x.Expiration, false)
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv35 := &x.TTL
+ yym36 := z.DecBinary()
+ _ = yym36
+ if false {
+ } else {
+ *((*int64)(yyv35)) = int64(r.DecodeInt(64))
+ }
+ }
+ for {
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj20-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x Nodes) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ h.encNodes((Nodes)(x), e)
+ }
+ }
+}
+
+func (x *Nodes) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ h.decNodes((*Nodes)(x), d)
+ }
+}
+
+func (x *httpKeysAPI) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(0)
+ } else {
+ r.WriteMapStart(0)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *httpKeysAPI) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *httpKeysAPI) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *httpKeysAPI) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj4 int
+ var yyb4 bool
+ var yyhl4 bool = l >= 0
+ for {
+ yyj4++
+ if yyhl4 {
+ yyb4 = yyj4 > l
+ } else {
+ yyb4 = r.CheckBreak()
+ }
+ if yyb4 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj4-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *httpWatcher) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(0)
+ } else {
+ r.WriteMapStart(0)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *httpWatcher) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *httpWatcher) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *httpWatcher) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj4 int
+ var yyb4 bool
+ var yyhl4 bool = l >= 0
+ for {
+ yyj4++
+ if yyhl4 {
+ yyb4 = yyj4 > l
+ } else {
+ yyb4 = r.CheckBreak()
+ }
+ if yyb4 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj4-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *getAction) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(5)
+ } else {
+ r.WriteMapStart(5)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Prefix"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Key"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Recursive"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Sorted))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Sorted"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Sorted))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym16 := z.EncBinary()
+ _ = yym16
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Quorum))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Quorum"))
+ r.WriteMapElemValue()
+ yym17 := z.EncBinary()
+ _ = yym17
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Quorum))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *getAction) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *getAction) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "Prefix":
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv4 := &x.Prefix
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "Key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv6 := &x.Key
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*string)(yyv6)) = r.DecodeString()
+ }
+ }
+ case "Recursive":
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv8 := &x.Recursive
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*bool)(yyv8)) = r.DecodeBool()
+ }
+ }
+ case "Sorted":
+ if r.TryDecodeAsNil() {
+ x.Sorted = false
+ } else {
+ yyv10 := &x.Sorted
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else {
+ *((*bool)(yyv10)) = r.DecodeBool()
+ }
+ }
+ case "Quorum":
+ if r.TryDecodeAsNil() {
+ x.Quorum = false
+ } else {
+ yyv12 := &x.Quorum
+ yym13 := z.DecBinary()
+ _ = yym13
+ if false {
+ } else {
+ *((*bool)(yyv12)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *getAction) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj14 int
+ var yyb14 bool
+ var yyhl14 bool = l >= 0
+ yyj14++
+ if yyhl14 {
+ yyb14 = yyj14 > l
+ } else {
+ yyb14 = r.CheckBreak()
+ }
+ if yyb14 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv15 := &x.Prefix
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*string)(yyv15)) = r.DecodeString()
+ }
+ }
+ yyj14++
+ if yyhl14 {
+ yyb14 = yyj14 > l
+ } else {
+ yyb14 = r.CheckBreak()
+ }
+ if yyb14 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv17 := &x.Key
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*string)(yyv17)) = r.DecodeString()
+ }
+ }
+ yyj14++
+ if yyhl14 {
+ yyb14 = yyj14 > l
+ } else {
+ yyb14 = r.CheckBreak()
+ }
+ if yyb14 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv19 := &x.Recursive
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else {
+ *((*bool)(yyv19)) = r.DecodeBool()
+ }
+ }
+ yyj14++
+ if yyhl14 {
+ yyb14 = yyj14 > l
+ } else {
+ yyb14 = r.CheckBreak()
+ }
+ if yyb14 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Sorted = false
+ } else {
+ yyv21 := &x.Sorted
+ yym22 := z.DecBinary()
+ _ = yym22
+ if false {
+ } else {
+ *((*bool)(yyv21)) = r.DecodeBool()
+ }
+ }
+ yyj14++
+ if yyhl14 {
+ yyb14 = yyj14 > l
+ } else {
+ yyb14 = r.CheckBreak()
+ }
+ if yyb14 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Quorum = false
+ } else {
+ yyv23 := &x.Quorum
+ yym24 := z.DecBinary()
+ _ = yym24
+ if false {
+ } else {
+ *((*bool)(yyv23)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj14++
+ if yyhl14 {
+ yyb14 = yyj14 > l
+ } else {
+ yyb14 = r.CheckBreak()
+ }
+ if yyb14 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj14-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *waitAction) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(4)
+ } else {
+ r.WriteMapStart(4)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Prefix"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Key"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.WaitIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("WaitIndex"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.WaitIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Recursive"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *waitAction) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *waitAction) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "Prefix":
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv4 := &x.Prefix
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "Key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv6 := &x.Key
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*string)(yyv6)) = r.DecodeString()
+ }
+ }
+ case "WaitIndex":
+ if r.TryDecodeAsNil() {
+ x.WaitIndex = 0
+ } else {
+ yyv8 := &x.WaitIndex
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*uint64)(yyv8)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "Recursive":
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv10 := &x.Recursive
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else {
+ *((*bool)(yyv10)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *waitAction) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj12 int
+ var yyb12 bool
+ var yyhl12 bool = l >= 0
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv13 := &x.Prefix
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*string)(yyv13)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv15 := &x.Key
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*string)(yyv15)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.WaitIndex = 0
+ } else {
+ yyv17 := &x.WaitIndex
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*uint64)(yyv17)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv19 := &x.Recursive
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else {
+ *((*bool)(yyv19)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj12-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *setAction) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(10)
+ } else {
+ r.WriteMapStart(10)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Prefix"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Key"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Value))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Value"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Value))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevValue"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym16 := z.EncBinary()
+ _ = yym16
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevIndex"))
+ r.WriteMapElemValue()
+ yym17 := z.EncBinary()
+ _ = yym17
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ x.PrevExist.CodecEncodeSelf(e)
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevExist"))
+ r.WriteMapElemValue()
+ x.PrevExist.CodecEncodeSelf(e)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym22 := z.EncBinary()
+ _ = yym22
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("TTL"))
+ r.WriteMapElemValue()
+ yym23 := z.EncBinary()
+ _ = yym23
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym25 := z.EncBinary()
+ _ = yym25
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Refresh))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Refresh"))
+ r.WriteMapElemValue()
+ yym26 := z.EncBinary()
+ _ = yym26
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Refresh))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym28 := z.EncBinary()
+ _ = yym28
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Dir"))
+ r.WriteMapElemValue()
+ yym29 := z.EncBinary()
+ _ = yym29
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym31 := z.EncBinary()
+ _ = yym31
+ if false {
+ } else {
+ r.EncodeBool(bool(x.NoValueOnSuccess))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("NoValueOnSuccess"))
+ r.WriteMapElemValue()
+ yym32 := z.EncBinary()
+ _ = yym32
+ if false {
+ } else {
+ r.EncodeBool(bool(x.NoValueOnSuccess))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *setAction) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *setAction) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "Prefix":
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv4 := &x.Prefix
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "Key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv6 := &x.Key
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*string)(yyv6)) = r.DecodeString()
+ }
+ }
+ case "Value":
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv8 := &x.Value
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*string)(yyv8)) = r.DecodeString()
+ }
+ }
+ case "PrevValue":
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv10 := &x.PrevValue
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else {
+ *((*string)(yyv10)) = r.DecodeString()
+ }
+ }
+ case "PrevIndex":
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv12 := &x.PrevIndex
+ yym13 := z.DecBinary()
+ _ = yym13
+ if false {
+ } else {
+ *((*uint64)(yyv12)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "PrevExist":
+ if r.TryDecodeAsNil() {
+ x.PrevExist = ""
+ } else {
+ yyv14 := &x.PrevExist
+ yyv14.CodecDecodeSelf(d)
+ }
+ case "TTL":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv15 := &x.TTL
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv15) {
+ } else {
+ *((*int64)(yyv15)) = int64(r.DecodeInt(64))
+ }
+ }
+ case "Refresh":
+ if r.TryDecodeAsNil() {
+ x.Refresh = false
+ } else {
+ yyv17 := &x.Refresh
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*bool)(yyv17)) = r.DecodeBool()
+ }
+ }
+ case "Dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv19 := &x.Dir
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else {
+ *((*bool)(yyv19)) = r.DecodeBool()
+ }
+ }
+ case "NoValueOnSuccess":
+ if r.TryDecodeAsNil() {
+ x.NoValueOnSuccess = false
+ } else {
+ yyv21 := &x.NoValueOnSuccess
+ yym22 := z.DecBinary()
+ _ = yym22
+ if false {
+ } else {
+ *((*bool)(yyv21)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *setAction) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj23 int
+ var yyb23 bool
+ var yyhl23 bool = l >= 0
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv24 := &x.Prefix
+ yym25 := z.DecBinary()
+ _ = yym25
+ if false {
+ } else {
+ *((*string)(yyv24)) = r.DecodeString()
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv26 := &x.Key
+ yym27 := z.DecBinary()
+ _ = yym27
+ if false {
+ } else {
+ *((*string)(yyv26)) = r.DecodeString()
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv28 := &x.Value
+ yym29 := z.DecBinary()
+ _ = yym29
+ if false {
+ } else {
+ *((*string)(yyv28)) = r.DecodeString()
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv30 := &x.PrevValue
+ yym31 := z.DecBinary()
+ _ = yym31
+ if false {
+ } else {
+ *((*string)(yyv30)) = r.DecodeString()
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv32 := &x.PrevIndex
+ yym33 := z.DecBinary()
+ _ = yym33
+ if false {
+ } else {
+ *((*uint64)(yyv32)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevExist = ""
+ } else {
+ yyv34 := &x.PrevExist
+ yyv34.CodecDecodeSelf(d)
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv35 := &x.TTL
+ yym36 := z.DecBinary()
+ _ = yym36
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv35) {
+ } else {
+ *((*int64)(yyv35)) = int64(r.DecodeInt(64))
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Refresh = false
+ } else {
+ yyv37 := &x.Refresh
+ yym38 := z.DecBinary()
+ _ = yym38
+ if false {
+ } else {
+ *((*bool)(yyv37)) = r.DecodeBool()
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv39 := &x.Dir
+ yym40 := z.DecBinary()
+ _ = yym40
+ if false {
+ } else {
+ *((*bool)(yyv39)) = r.DecodeBool()
+ }
+ }
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.NoValueOnSuccess = false
+ } else {
+ yyv41 := &x.NoValueOnSuccess
+ yym42 := z.DecBinary()
+ _ = yym42
+ if false {
+ } else {
+ *((*bool)(yyv41)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj23++
+ if yyhl23 {
+ yyb23 = yyj23 > l
+ } else {
+ yyb23 = r.CheckBreak()
+ }
+ if yyb23 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj23-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *deleteAction) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(6)
+ } else {
+ r.WriteMapStart(6)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Prefix"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Key"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Key))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevValue"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.PrevValue))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("PrevIndex"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.PrevIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym16 := z.EncBinary()
+ _ = yym16
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Dir"))
+ r.WriteMapElemValue()
+ yym17 := z.EncBinary()
+ _ = yym17
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym19 := z.EncBinary()
+ _ = yym19
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Recursive"))
+ r.WriteMapElemValue()
+ yym20 := z.EncBinary()
+ _ = yym20
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Recursive))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *deleteAction) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *deleteAction) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "Prefix":
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv4 := &x.Prefix
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "Key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv6 := &x.Key
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*string)(yyv6)) = r.DecodeString()
+ }
+ }
+ case "PrevValue":
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv8 := &x.PrevValue
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*string)(yyv8)) = r.DecodeString()
+ }
+ }
+ case "PrevIndex":
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv10 := &x.PrevIndex
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else {
+ *((*uint64)(yyv10)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "Dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv12 := &x.Dir
+ yym13 := z.DecBinary()
+ _ = yym13
+ if false {
+ } else {
+ *((*bool)(yyv12)) = r.DecodeBool()
+ }
+ }
+ case "Recursive":
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv14 := &x.Recursive
+ yym15 := z.DecBinary()
+ _ = yym15
+ if false {
+ } else {
+ *((*bool)(yyv14)) = r.DecodeBool()
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *deleteAction) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj16 int
+ var yyb16 bool
+ var yyhl16 bool = l >= 0
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv17 := &x.Prefix
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*string)(yyv17)) = r.DecodeString()
+ }
+ }
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv19 := &x.Key
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else {
+ *((*string)(yyv19)) = r.DecodeString()
+ }
+ }
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevValue = ""
+ } else {
+ yyv21 := &x.PrevValue
+ yym22 := z.DecBinary()
+ _ = yym22
+ if false {
+ } else {
+ *((*string)(yyv21)) = r.DecodeString()
+ }
+ }
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.PrevIndex = 0
+ } else {
+ yyv23 := &x.PrevIndex
+ yym24 := z.DecBinary()
+ _ = yym24
+ if false {
+ } else {
+ *((*uint64)(yyv23)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv25 := &x.Dir
+ yym26 := z.DecBinary()
+ _ = yym26
+ if false {
+ } else {
+ *((*bool)(yyv25)) = r.DecodeBool()
+ }
+ }
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Recursive = false
+ } else {
+ yyv27 := &x.Recursive
+ yym28 := z.DecBinary()
+ _ = yym28
+ if false {
+ } else {
+ *((*bool)(yyv27)) = r.DecodeBool()
+ }
+ }
+ for {
+ yyj16++
+ if yyhl16 {
+ yyb16 = yyj16 > l
+ } else {
+ yyb16 = r.CheckBreak()
+ }
+ if yyb16 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj16-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x *createInOrderAction) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ _, _ = yysep2, yy2arr2
+ const yyr2 bool = false
+ if yyr2 || yy2arr2 {
+ r.WriteArrayStart(4)
+ } else {
+ r.WriteMapStart(4)
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Prefix"))
+ r.WriteMapElemValue()
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Prefix))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Dir))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Dir"))
+ r.WriteMapElemValue()
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Dir))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Value))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("Value"))
+ r.WriteMapElemValue()
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF87612, string(x.Value))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayElem()
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.WriteMapElemKey()
+ r.EncodeString(codecSelferC_UTF87612, string("TTL"))
+ r.WriteMapElemValue()
+ yym14 := z.EncBinary()
+ _ = yym14
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.TTL) {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ r.WriteArrayEnd()
+ } else {
+ r.WriteMapEnd()
+ }
+ }
+ }
+}
+
+func (x *createInOrderAction) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap7612 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ r.ReadMapEnd()
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray7612 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ r.ReadArrayEnd()
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr7612)
+ }
+ }
+}
+
+func (x *createInOrderAction) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ r.ReadMapElemKey()
+ yys3Slc = r.DecodeStringAsBytes()
+ yys3 := string(yys3Slc)
+ r.ReadMapElemValue()
+ switch yys3 {
+ case "Prefix":
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv4 := &x.Prefix
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "Dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = ""
+ } else {
+ yyv6 := &x.Dir
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*string)(yyv6)) = r.DecodeString()
+ }
+ }
+ case "Value":
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv8 := &x.Value
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*string)(yyv8)) = r.DecodeString()
+ }
+ }
+ case "TTL":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv10 := &x.TTL
+ yym11 := z.DecBinary()
+ _ = yym11
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv10) {
+ } else {
+ *((*int64)(yyv10)) = int64(r.DecodeInt(64))
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ r.ReadMapEnd()
+}
+
+func (x *createInOrderAction) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj12 int
+ var yyb12 bool
+ var yyhl12 bool = l >= 0
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Prefix = ""
+ } else {
+ yyv13 := &x.Prefix
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*string)(yyv13)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Dir = ""
+ } else {
+ yyv15 := &x.Dir
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else {
+ *((*string)(yyv15)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv17 := &x.Value
+ yym18 := z.DecBinary()
+ _ = yym18
+ if false {
+ } else {
+ *((*string)(yyv17)) = r.DecodeString()
+ }
+ }
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ r.ReadArrayEnd()
+ return
+ }
+ r.ReadArrayElem()
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv19 := &x.TTL
+ yym20 := z.DecBinary()
+ _ = yym20
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv19) {
+ } else {
+ *((*int64)(yyv19)) = int64(r.DecodeInt(64))
+ }
+ }
+ for {
+ yyj12++
+ if yyhl12 {
+ yyb12 = yyj12 > l
+ } else {
+ yyb12 = r.CheckBreak()
+ }
+ if yyb12 {
+ break
+ }
+ r.ReadArrayElem()
+ z.DecStructFieldNotFound(yyj12-1, "")
+ }
+ r.ReadArrayEnd()
+}
+
+func (x codecSelfer7612) encNodes(v Nodes, e *codec1978.Encoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ r.WriteArrayStart(len(v))
+ for _, yyv1 := range v {
+ r.WriteArrayElem()
+ if yyv1 == nil {
+ r.EncodeNil()
+ } else {
+ yyv1.CodecEncodeSelf(e)
+ }
+ }
+ r.WriteArrayEnd()
+}
+
+func (x codecSelfer7612) decNodes(v *Nodes, d *codec1978.Decoder) {
+ var h codecSelfer7612
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+
+ yyv1 := *v
+ yyh1, yyl1 := z.DecSliceHelperStart()
+ var yyc1 bool
+ _ = yyc1
+ if yyl1 == 0 {
+ if yyv1 == nil {
+ yyv1 = []*Node{}
+ yyc1 = true
+ } else if len(yyv1) != 0 {
+ yyv1 = yyv1[:0]
+ yyc1 = true
+ }
+ } else {
+ yyhl1 := yyl1 > 0
+ var yyrl1 int
+ _ = yyrl1
+ if yyhl1 {
+ if yyl1 > cap(yyv1) {
+ yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8)
+ if yyrl1 <= cap(yyv1) {
+ yyv1 = yyv1[:yyrl1]
+ } else {
+ yyv1 = make([]*Node, yyrl1)
+ }
+ yyc1 = true
+ } else if yyl1 != len(yyv1) {
+ yyv1 = yyv1[:yyl1]
+ yyc1 = true
+ }
+ }
+ var yyj1 int
+ // var yydn1 bool
+ for ; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || r.CheckBreak()); yyj1++ {
+ if yyj1 == 0 && len(yyv1) == 0 {
+ if yyhl1 {
+ yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8)
+ } else {
+ yyrl1 = 8
+ }
+ yyv1 = make([]*Node, yyrl1)
+ yyc1 = true
+ }
+ yyh1.ElemContainerState(yyj1)
+ // yydn1 = r.TryDecodeAsNil()
+
+ // if indefinite, etc, then expand the slice if necessary
+ var yydb1 bool
+ if yyj1 >= len(yyv1) {
+ yyv1 = append(yyv1, nil)
+ yyc1 = true
+
+ }
+ if yydb1 {
+ z.DecSwallow()
+ } else {
+ if r.TryDecodeAsNil() {
+ if yyv1[yyj1] != nil {
+ *yyv1[yyj1] = Node{}
+ }
+ } else {
+ if yyv1[yyj1] == nil {
+ yyv1[yyj1] = new(Node)
+ }
+ yyw2 := yyv1[yyj1]
+ yyw2.CodecDecodeSelf(d)
+ }
+
+ }
+
+ }
+ if yyj1 < len(yyv1) {
+ yyv1 = yyv1[:yyj1]
+ yyc1 = true
+ } else if yyj1 == 0 && yyv1 == nil {
+ yyv1 = make([]*Node, 0)
+ yyc1 = true
+ }
+ }
+ yyh1.End()
+ if yyc1 {
+ *v = yyv1
+ }
+
+}
diff --git a/vendor/github.com/coreos/etcd/client/keys.go b/vendor/github.com/coreos/etcd/client/keys.go
new file mode 100644
index 00000000..8b9fd3f8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/keys.go
@@ -0,0 +1,681 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+//go:generate codecgen -d 1819 -r "Node|Response|Nodes" -o keys.generated.go keys.go
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/pkg/pathutil"
+ "github.com/ugorji/go/codec"
+)
+
+const (
+ ErrorCodeKeyNotFound = 100
+ ErrorCodeTestFailed = 101
+ ErrorCodeNotFile = 102
+ ErrorCodeNotDir = 104
+ ErrorCodeNodeExist = 105
+ ErrorCodeRootROnly = 107
+ ErrorCodeDirNotEmpty = 108
+ ErrorCodeUnauthorized = 110
+
+ ErrorCodePrevValueRequired = 201
+ ErrorCodeTTLNaN = 202
+ ErrorCodeIndexNaN = 203
+ ErrorCodeInvalidField = 209
+ ErrorCodeInvalidForm = 210
+
+ ErrorCodeRaftInternal = 300
+ ErrorCodeLeaderElect = 301
+
+ ErrorCodeWatcherCleared = 400
+ ErrorCodeEventIndexCleared = 401
+)
+
+type Error struct {
+ Code int `json:"errorCode"`
+ Message string `json:"message"`
+ Cause string `json:"cause"`
+ Index uint64 `json:"index"`
+}
+
+func (e Error) Error() string {
+ return fmt.Sprintf("%v: %v (%v) [%v]", e.Code, e.Message, e.Cause, e.Index)
+}
+
+var (
+ ErrInvalidJSON = errors.New("client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.")
+ ErrEmptyBody = errors.New("client: response body is empty")
+)
+
+// PrevExistType is used to define an existence condition when setting
+// or deleting Nodes.
+type PrevExistType string
+
+const (
+ PrevIgnore = PrevExistType("")
+ PrevExist = PrevExistType("true")
+ PrevNoExist = PrevExistType("false")
+)
+
+var (
+ defaultV2KeysPrefix = "/v2/keys"
+)
+
+// NewKeysAPI builds a KeysAPI that interacts with etcd's key-value
+// API over HTTP.
+func NewKeysAPI(c Client) KeysAPI {
+ return NewKeysAPIWithPrefix(c, defaultV2KeysPrefix)
+}
+
+// NewKeysAPIWithPrefix acts like NewKeysAPI, but allows the caller
+// to provide a custom base URL path. This should only be used in
+// very rare cases.
+func NewKeysAPIWithPrefix(c Client, p string) KeysAPI {
+ return &httpKeysAPI{
+ client: c,
+ prefix: p,
+ }
+}
+
+type KeysAPI interface {
+ // Get retrieves a set of Nodes from etcd
+ Get(ctx context.Context, key string, opts *GetOptions) (*Response, error)
+
+ // Set assigns a new value to a Node identified by a given key. The caller
+ // may define a set of conditions in the SetOptions. If SetOptions.Dir=true
+ // then value is ignored.
+ Set(ctx context.Context, key, value string, opts *SetOptions) (*Response, error)
+
+ // Delete removes a Node identified by the given key, optionally destroying
+ // all of its children as well. The caller may define a set of required
+ // conditions in an DeleteOptions object.
+ Delete(ctx context.Context, key string, opts *DeleteOptions) (*Response, error)
+
+ // Create is an alias for Set w/ PrevExist=false
+ Create(ctx context.Context, key, value string) (*Response, error)
+
+ // CreateInOrder is used to atomically create in-order keys within the given directory.
+ CreateInOrder(ctx context.Context, dir, value string, opts *CreateInOrderOptions) (*Response, error)
+
+ // Update is an alias for Set w/ PrevExist=true
+ Update(ctx context.Context, key, value string) (*Response, error)
+
+ // Watcher builds a new Watcher targeted at a specific Node identified
+ // by the given key. The Watcher may be configured at creation time
+ // through a WatcherOptions object. The returned Watcher is designed
+ // to emit events that happen to a Node, and optionally to its children.
+ Watcher(key string, opts *WatcherOptions) Watcher
+}
+
+type WatcherOptions struct {
+ // AfterIndex defines the index after-which the Watcher should
+ // start emitting events. For example, if a value of 5 is
+ // provided, the first event will have an index >= 6.
+ //
+ // Setting AfterIndex to 0 (default) means that the Watcher
+ // should start watching for events starting at the current
+ // index, whatever that may be.
+ AfterIndex uint64
+
+ // Recursive specifies whether or not the Watcher should emit
+ // events that occur in children of the given keyspace. If set
+ // to false (default), events will be limited to those that
+ // occur for the exact key.
+ Recursive bool
+}
+
+type CreateInOrderOptions struct {
+ // TTL defines a period of time after-which the Node should
+ // expire and no longer exist. Values <= 0 are ignored. Given
+ // that the zero-value is ignored, TTL cannot be used to set
+ // a TTL of 0.
+ TTL time.Duration
+}
+
+type SetOptions struct {
+ // PrevValue specifies what the current value of the Node must
+ // be in order for the Set operation to succeed.
+ //
+ // Leaving this field empty means that the caller wishes to
+ // ignore the current value of the Node. This cannot be used
+ // to compare the Node's current value to an empty string.
+ //
+ // PrevValue is ignored if Dir=true
+ PrevValue string
+
+ // PrevIndex indicates what the current ModifiedIndex of the
+ // Node must be in order for the Set operation to succeed.
+ //
+ // If PrevIndex is set to 0 (default), no comparison is made.
+ PrevIndex uint64
+
+ // PrevExist specifies whether the Node must currently exist
+ // (PrevExist) or not (PrevNoExist). If the caller does not
+ // care about existence, set PrevExist to PrevIgnore, or simply
+ // leave it unset.
+ PrevExist PrevExistType
+
+ // TTL defines a period of time after-which the Node should
+ // expire and no longer exist. Values <= 0 are ignored. Given
+ // that the zero-value is ignored, TTL cannot be used to set
+ // a TTL of 0.
+ TTL time.Duration
+
+ // Refresh set to true means a TTL value can be updated
+ // without firing a watch or changing the node value. A
+ // value must not be provided when refreshing a key.
+ Refresh bool
+
+ // Dir specifies whether or not this Node should be created as a directory.
+ Dir bool
+
+ // NoValueOnSuccess specifies whether the response contains the current value of the Node.
+ // If set, the response will only contain the current value when the request fails.
+ NoValueOnSuccess bool
+}
+
+type GetOptions struct {
+ // Recursive defines whether or not all children of the Node
+ // should be returned.
+ Recursive bool
+
+ // Sort instructs the server whether or not to sort the Nodes.
+ // If true, the Nodes are sorted alphabetically by key in
+ // ascending order (A to z). If false (default), the Nodes will
+ // not be sorted and the ordering used should not be considered
+ // predictable.
+ Sort bool
+
+ // Quorum specifies whether it gets the latest committed value that
+ // has been applied in quorum of members, which ensures external
+ // consistency (or linearizability).
+ Quorum bool
+}
+
+type DeleteOptions struct {
+ // PrevValue specifies what the current value of the Node must
+ // be in order for the Delete operation to succeed.
+ //
+ // Leaving this field empty means that the caller wishes to
+ // ignore the current value of the Node. This cannot be used
+ // to compare the Node's current value to an empty string.
+ PrevValue string
+
+ // PrevIndex indicates what the current ModifiedIndex of the
+ // Node must be in order for the Delete operation to succeed.
+ //
+ // If PrevIndex is set to 0 (default), no comparison is made.
+ PrevIndex uint64
+
+ // Recursive defines whether or not all children of the Node
+ // should be deleted. If set to true, all children of the Node
+ // identified by the given key will be deleted. If left unset
+ // or explicitly set to false, only a single Node will be
+ // deleted.
+ Recursive bool
+
+ // Dir specifies whether or not this Node should be removed as a directory.
+ Dir bool
+}
+
+type Watcher interface {
+ // Next blocks until an etcd event occurs, then returns a Response
+ // representing that event. The behavior of Next depends on the
+ // WatcherOptions used to construct the Watcher. Next is designed to
+ // be called repeatedly, each time blocking until a subsequent event
+ // is available.
+ //
+ // If the provided context is cancelled, Next will return a non-nil
+ // error. Any other failures encountered while waiting for the next
+ // event (connection issues, deserialization failures, etc) will
+ // also result in a non-nil error.
+ Next(context.Context) (*Response, error)
+}
+
+type Response struct {
+ // Action is the name of the operation that occurred. Possible values
+ // include get, set, delete, update, create, compareAndSwap,
+ // compareAndDelete and expire.
+ Action string `json:"action"`
+
+ // Node represents the state of the relevant etcd Node.
+ Node *Node `json:"node"`
+
+ // PrevNode represents the previous state of the Node. PrevNode is non-nil
+ // only if the Node existed before the action occurred and the action
+ // caused a change to the Node.
+ PrevNode *Node `json:"prevNode"`
+
+ // Index holds the cluster-level index at the time the Response was generated.
+ // This index is not tied to the Node(s) contained in this Response.
+ Index uint64 `json:"-"`
+
+ // ClusterID holds the cluster-level ID reported by the server. This
+ // should be different for different etcd clusters.
+ ClusterID string `json:"-"`
+}
+
+type Node struct {
+ // Key represents the unique location of this Node (e.g. "/foo/bar").
+ Key string `json:"key"`
+
+ // Dir reports whether node describes a directory.
+ Dir bool `json:"dir,omitempty"`
+
+ // Value is the current data stored on this Node. If this Node
+ // is a directory, Value will be empty.
+ Value string `json:"value"`
+
+ // Nodes holds the children of this Node, only if this Node is a directory.
+ // This slice of will be arbitrarily deep (children, grandchildren, great-
+ // grandchildren, etc.) if a recursive Get or Watch request were made.
+ Nodes Nodes `json:"nodes"`
+
+ // CreatedIndex is the etcd index at-which this Node was created.
+ CreatedIndex uint64 `json:"createdIndex"`
+
+ // ModifiedIndex is the etcd index at-which this Node was last modified.
+ ModifiedIndex uint64 `json:"modifiedIndex"`
+
+ // Expiration is the server side expiration time of the key.
+ Expiration *time.Time `json:"expiration,omitempty"`
+
+ // TTL is the time to live of the key in second.
+ TTL int64 `json:"ttl,omitempty"`
+}
+
+func (n *Node) String() string {
+ return fmt.Sprintf("{Key: %s, CreatedIndex: %d, ModifiedIndex: %d, TTL: %d}", n.Key, n.CreatedIndex, n.ModifiedIndex, n.TTL)
+}
+
+// TTLDuration returns the Node's TTL as a time.Duration object
+func (n *Node) TTLDuration() time.Duration {
+ return time.Duration(n.TTL) * time.Second
+}
+
+type Nodes []*Node
+
+// interfaces for sorting
+
+func (ns Nodes) Len() int { return len(ns) }
+func (ns Nodes) Less(i, j int) bool { return ns[i].Key < ns[j].Key }
+func (ns Nodes) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] }
+
+type httpKeysAPI struct {
+ client httpClient
+ prefix string
+}
+
+func (k *httpKeysAPI) Set(ctx context.Context, key, val string, opts *SetOptions) (*Response, error) {
+ act := &setAction{
+ Prefix: k.prefix,
+ Key: key,
+ Value: val,
+ }
+
+ if opts != nil {
+ act.PrevValue = opts.PrevValue
+ act.PrevIndex = opts.PrevIndex
+ act.PrevExist = opts.PrevExist
+ act.TTL = opts.TTL
+ act.Refresh = opts.Refresh
+ act.Dir = opts.Dir
+ act.NoValueOnSuccess = opts.NoValueOnSuccess
+ }
+
+ doCtx := ctx
+ if act.PrevExist == PrevNoExist {
+ doCtx = context.WithValue(doCtx, &oneShotCtxValue, &oneShotCtxValue)
+ }
+ resp, body, err := k.client.Do(doCtx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Create(ctx context.Context, key, val string) (*Response, error) {
+ return k.Set(ctx, key, val, &SetOptions{PrevExist: PrevNoExist})
+}
+
+func (k *httpKeysAPI) CreateInOrder(ctx context.Context, dir, val string, opts *CreateInOrderOptions) (*Response, error) {
+ act := &createInOrderAction{
+ Prefix: k.prefix,
+ Dir: dir,
+ Value: val,
+ }
+
+ if opts != nil {
+ act.TTL = opts.TTL
+ }
+
+ resp, body, err := k.client.Do(ctx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Update(ctx context.Context, key, val string) (*Response, error) {
+ return k.Set(ctx, key, val, &SetOptions{PrevExist: PrevExist})
+}
+
+func (k *httpKeysAPI) Delete(ctx context.Context, key string, opts *DeleteOptions) (*Response, error) {
+ act := &deleteAction{
+ Prefix: k.prefix,
+ Key: key,
+ }
+
+ if opts != nil {
+ act.PrevValue = opts.PrevValue
+ act.PrevIndex = opts.PrevIndex
+ act.Dir = opts.Dir
+ act.Recursive = opts.Recursive
+ }
+
+ doCtx := context.WithValue(ctx, &oneShotCtxValue, &oneShotCtxValue)
+ resp, body, err := k.client.Do(doCtx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Get(ctx context.Context, key string, opts *GetOptions) (*Response, error) {
+ act := &getAction{
+ Prefix: k.prefix,
+ Key: key,
+ }
+
+ if opts != nil {
+ act.Recursive = opts.Recursive
+ act.Sorted = opts.Sort
+ act.Quorum = opts.Quorum
+ }
+
+ resp, body, err := k.client.Do(ctx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Watcher(key string, opts *WatcherOptions) Watcher {
+ act := waitAction{
+ Prefix: k.prefix,
+ Key: key,
+ }
+
+ if opts != nil {
+ act.Recursive = opts.Recursive
+ if opts.AfterIndex > 0 {
+ act.WaitIndex = opts.AfterIndex + 1
+ }
+ }
+
+ return &httpWatcher{
+ client: k.client,
+ nextWait: act,
+ }
+}
+
+type httpWatcher struct {
+ client httpClient
+ nextWait waitAction
+}
+
+func (hw *httpWatcher) Next(ctx context.Context) (*Response, error) {
+ for {
+ httpresp, body, err := hw.client.Do(ctx, &hw.nextWait)
+ if err != nil {
+ return nil, err
+ }
+
+ resp, err := unmarshalHTTPResponse(httpresp.StatusCode, httpresp.Header, body)
+ if err != nil {
+ if err == ErrEmptyBody {
+ continue
+ }
+ return nil, err
+ }
+
+ hw.nextWait.WaitIndex = resp.Node.ModifiedIndex + 1
+ return resp, nil
+ }
+}
+
+// v2KeysURL forms a URL representing the location of a key.
+// The endpoint argument represents the base URL of an etcd
+// server. The prefix is the path needed to route from the
+// provided endpoint's path to the root of the keys API
+// (typically "/v2/keys").
+func v2KeysURL(ep url.URL, prefix, key string) *url.URL {
+ // We concatenate all parts together manually. We cannot use
+ // path.Join because it does not reserve trailing slash.
+ // We call CanonicalURLPath to further cleanup the path.
+ if prefix != "" && prefix[0] != '/' {
+ prefix = "/" + prefix
+ }
+ if key != "" && key[0] != '/' {
+ key = "/" + key
+ }
+ ep.Path = pathutil.CanonicalURLPath(ep.Path + prefix + key)
+ return &ep
+}
+
+type getAction struct {
+ Prefix string
+ Key string
+ Recursive bool
+ Sorted bool
+ Quorum bool
+}
+
+func (g *getAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, g.Prefix, g.Key)
+
+ params := u.Query()
+ params.Set("recursive", strconv.FormatBool(g.Recursive))
+ params.Set("sorted", strconv.FormatBool(g.Sorted))
+ params.Set("quorum", strconv.FormatBool(g.Quorum))
+ u.RawQuery = params.Encode()
+
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+type waitAction struct {
+ Prefix string
+ Key string
+ WaitIndex uint64
+ Recursive bool
+}
+
+func (w *waitAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, w.Prefix, w.Key)
+
+ params := u.Query()
+ params.Set("wait", "true")
+ params.Set("waitIndex", strconv.FormatUint(w.WaitIndex, 10))
+ params.Set("recursive", strconv.FormatBool(w.Recursive))
+ u.RawQuery = params.Encode()
+
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+type setAction struct {
+ Prefix string
+ Key string
+ Value string
+ PrevValue string
+ PrevIndex uint64
+ PrevExist PrevExistType
+ TTL time.Duration
+ Refresh bool
+ Dir bool
+ NoValueOnSuccess bool
+}
+
+func (a *setAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, a.Prefix, a.Key)
+
+ params := u.Query()
+ form := url.Values{}
+
+ // we're either creating a directory or setting a key
+ if a.Dir {
+ params.Set("dir", strconv.FormatBool(a.Dir))
+ } else {
+ // These options are only valid for setting a key
+ if a.PrevValue != "" {
+ params.Set("prevValue", a.PrevValue)
+ }
+ form.Add("value", a.Value)
+ }
+
+ // Options which apply to both setting a key and creating a dir
+ if a.PrevIndex != 0 {
+ params.Set("prevIndex", strconv.FormatUint(a.PrevIndex, 10))
+ }
+ if a.PrevExist != PrevIgnore {
+ params.Set("prevExist", string(a.PrevExist))
+ }
+ if a.TTL > 0 {
+ form.Add("ttl", strconv.FormatUint(uint64(a.TTL.Seconds()), 10))
+ }
+
+ if a.Refresh {
+ form.Add("refresh", "true")
+ }
+ if a.NoValueOnSuccess {
+ params.Set("noValueOnSuccess", strconv.FormatBool(a.NoValueOnSuccess))
+ }
+
+ u.RawQuery = params.Encode()
+ body := strings.NewReader(form.Encode())
+
+ req, _ := http.NewRequest("PUT", u.String(), body)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+
+ return req
+}
+
+type deleteAction struct {
+ Prefix string
+ Key string
+ PrevValue string
+ PrevIndex uint64
+ Dir bool
+ Recursive bool
+}
+
+func (a *deleteAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, a.Prefix, a.Key)
+
+ params := u.Query()
+ if a.PrevValue != "" {
+ params.Set("prevValue", a.PrevValue)
+ }
+ if a.PrevIndex != 0 {
+ params.Set("prevIndex", strconv.FormatUint(a.PrevIndex, 10))
+ }
+ if a.Dir {
+ params.Set("dir", "true")
+ }
+ if a.Recursive {
+ params.Set("recursive", "true")
+ }
+ u.RawQuery = params.Encode()
+
+ req, _ := http.NewRequest("DELETE", u.String(), nil)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+
+ return req
+}
+
+type createInOrderAction struct {
+ Prefix string
+ Dir string
+ Value string
+ TTL time.Duration
+}
+
+func (a *createInOrderAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, a.Prefix, a.Dir)
+
+ form := url.Values{}
+ form.Add("value", a.Value)
+ if a.TTL > 0 {
+ form.Add("ttl", strconv.FormatUint(uint64(a.TTL.Seconds()), 10))
+ }
+ body := strings.NewReader(form.Encode())
+
+ req, _ := http.NewRequest("POST", u.String(), body)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ return req
+}
+
+func unmarshalHTTPResponse(code int, header http.Header, body []byte) (res *Response, err error) {
+ switch code {
+ case http.StatusOK, http.StatusCreated:
+ if len(body) == 0 {
+ return nil, ErrEmptyBody
+ }
+ res, err = unmarshalSuccessfulKeysResponse(header, body)
+ default:
+ err = unmarshalFailedKeysResponse(body)
+ }
+ return res, err
+}
+
+func unmarshalSuccessfulKeysResponse(header http.Header, body []byte) (*Response, error) {
+ var res Response
+ err := codec.NewDecoderBytes(body, new(codec.JsonHandle)).Decode(&res)
+ if err != nil {
+ return nil, ErrInvalidJSON
+ }
+ if header.Get("X-Etcd-Index") != "" {
+ res.Index, err = strconv.ParseUint(header.Get("X-Etcd-Index"), 10, 64)
+ if err != nil {
+ return nil, err
+ }
+ }
+ res.ClusterID = header.Get("X-Etcd-Cluster-ID")
+ return &res, nil
+}
+
+func unmarshalFailedKeysResponse(body []byte) error {
+ var etcdErr Error
+ if err := json.Unmarshal(body, &etcdErr); err != nil {
+ return ErrInvalidJSON
+ }
+ return etcdErr
+}
diff --git a/vendor/github.com/coreos/etcd/client/members.go b/vendor/github.com/coreos/etcd/client/members.go
new file mode 100644
index 00000000..aafa3d1b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/members.go
@@ -0,0 +1,303 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/url"
+ "path"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+var (
+ defaultV2MembersPrefix = "/v2/members"
+ defaultLeaderSuffix = "/leader"
+)
+
+type Member struct {
+ // ID is the unique identifier of this Member.
+ ID string `json:"id"`
+
+ // Name is a human-readable, non-unique identifier of this Member.
+ Name string `json:"name"`
+
+ // PeerURLs represents the HTTP(S) endpoints this Member uses to
+ // participate in etcd's consensus protocol.
+ PeerURLs []string `json:"peerURLs"`
+
+ // ClientURLs represents the HTTP(S) endpoints on which this Member
+ // serves its client-facing APIs.
+ ClientURLs []string `json:"clientURLs"`
+}
+
+type memberCollection []Member
+
+func (c *memberCollection) UnmarshalJSON(data []byte) error {
+ d := struct {
+ Members []Member
+ }{}
+
+ if err := json.Unmarshal(data, &d); err != nil {
+ return err
+ }
+
+ if d.Members == nil {
+ *c = make([]Member, 0)
+ return nil
+ }
+
+ *c = d.Members
+ return nil
+}
+
+type memberCreateOrUpdateRequest struct {
+ PeerURLs types.URLs
+}
+
+func (m *memberCreateOrUpdateRequest) MarshalJSON() ([]byte, error) {
+ s := struct {
+ PeerURLs []string `json:"peerURLs"`
+ }{
+ PeerURLs: make([]string, len(m.PeerURLs)),
+ }
+
+ for i, u := range m.PeerURLs {
+ s.PeerURLs[i] = u.String()
+ }
+
+ return json.Marshal(&s)
+}
+
+// NewMembersAPI constructs a new MembersAPI that uses HTTP to
+// interact with etcd's membership API.
+func NewMembersAPI(c Client) MembersAPI {
+ return &httpMembersAPI{
+ client: c,
+ }
+}
+
+type MembersAPI interface {
+ // List enumerates the current cluster membership.
+ List(ctx context.Context) ([]Member, error)
+
+ // Add instructs etcd to accept a new Member into the cluster.
+ Add(ctx context.Context, peerURL string) (*Member, error)
+
+ // Remove demotes an existing Member out of the cluster.
+ Remove(ctx context.Context, mID string) error
+
+ // Update instructs etcd to update an existing Member in the cluster.
+ Update(ctx context.Context, mID string, peerURLs []string) error
+
+ // Leader gets current leader of the cluster
+ Leader(ctx context.Context) (*Member, error)
+}
+
+type httpMembersAPI struct {
+ client httpClient
+}
+
+func (m *httpMembersAPI) List(ctx context.Context) ([]Member, error) {
+ req := &membersAPIActionList{}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ return nil, err
+ }
+
+ var mCollection memberCollection
+ if err := json.Unmarshal(body, &mCollection); err != nil {
+ return nil, err
+ }
+
+ return []Member(mCollection), nil
+}
+
+func (m *httpMembersAPI) Add(ctx context.Context, peerURL string) (*Member, error) {
+ urls, err := types.NewURLs([]string{peerURL})
+ if err != nil {
+ return nil, err
+ }
+
+ req := &membersAPIActionAdd{peerURLs: urls}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusCreated, http.StatusConflict); err != nil {
+ return nil, err
+ }
+
+ if resp.StatusCode != http.StatusCreated {
+ var merr membersError
+ if err := json.Unmarshal(body, &merr); err != nil {
+ return nil, err
+ }
+ return nil, merr
+ }
+
+ var memb Member
+ if err := json.Unmarshal(body, &memb); err != nil {
+ return nil, err
+ }
+
+ return &memb, nil
+}
+
+func (m *httpMembersAPI) Update(ctx context.Context, memberID string, peerURLs []string) error {
+ urls, err := types.NewURLs(peerURLs)
+ if err != nil {
+ return err
+ }
+
+ req := &membersAPIActionUpdate{peerURLs: urls, memberID: memberID}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusNoContent, http.StatusNotFound, http.StatusConflict); err != nil {
+ return err
+ }
+
+ if resp.StatusCode != http.StatusNoContent {
+ var merr membersError
+ if err := json.Unmarshal(body, &merr); err != nil {
+ return err
+ }
+ return merr
+ }
+
+ return nil
+}
+
+func (m *httpMembersAPI) Remove(ctx context.Context, memberID string) error {
+ req := &membersAPIActionRemove{memberID: memberID}
+ resp, _, err := m.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+
+ return assertStatusCode(resp.StatusCode, http.StatusNoContent, http.StatusGone)
+}
+
+func (m *httpMembersAPI) Leader(ctx context.Context) (*Member, error) {
+ req := &membersAPIActionLeader{}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ return nil, err
+ }
+
+ var leader Member
+ if err := json.Unmarshal(body, &leader); err != nil {
+ return nil, err
+ }
+
+ return &leader, nil
+}
+
+type membersAPIActionList struct{}
+
+func (l *membersAPIActionList) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+type membersAPIActionRemove struct {
+ memberID string
+}
+
+func (d *membersAPIActionRemove) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ u.Path = path.Join(u.Path, d.memberID)
+ req, _ := http.NewRequest("DELETE", u.String(), nil)
+ return req
+}
+
+type membersAPIActionAdd struct {
+ peerURLs types.URLs
+}
+
+func (a *membersAPIActionAdd) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ m := memberCreateOrUpdateRequest{PeerURLs: a.peerURLs}
+ b, _ := json.Marshal(&m)
+ req, _ := http.NewRequest("POST", u.String(), bytes.NewReader(b))
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+type membersAPIActionUpdate struct {
+ memberID string
+ peerURLs types.URLs
+}
+
+func (a *membersAPIActionUpdate) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ m := memberCreateOrUpdateRequest{PeerURLs: a.peerURLs}
+ u.Path = path.Join(u.Path, a.memberID)
+ b, _ := json.Marshal(&m)
+ req, _ := http.NewRequest("PUT", u.String(), bytes.NewReader(b))
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func assertStatusCode(got int, want ...int) (err error) {
+ for _, w := range want {
+ if w == got {
+ return nil
+ }
+ }
+ return fmt.Errorf("unexpected status code %d", got)
+}
+
+type membersAPIActionLeader struct{}
+
+func (l *membersAPIActionLeader) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ u.Path = path.Join(u.Path, defaultLeaderSuffix)
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+// v2MembersURL add the necessary path to the provided endpoint
+// to route requests to the default v2 members API.
+func v2MembersURL(ep url.URL) *url.URL {
+ ep.Path = path.Join(ep.Path, defaultV2MembersPrefix)
+ return &ep
+}
+
+type membersError struct {
+ Message string `json:"message"`
+ Code int `json:"-"`
+}
+
+func (e membersError) Error() string {
+ return e.Message
+}
diff --git a/vendor/github.com/coreos/etcd/client/util.go b/vendor/github.com/coreos/etcd/client/util.go
new file mode 100644
index 00000000..15a8babf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/util.go
@@ -0,0 +1,53 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package client
+
+import (
+ "regexp"
+)
+
+var (
+ roleNotFoundRegExp *regexp.Regexp
+ userNotFoundRegExp *regexp.Regexp
+)
+
+func init() {
+ roleNotFoundRegExp = regexp.MustCompile("auth: Role .* does not exist.")
+ userNotFoundRegExp = regexp.MustCompile("auth: User .* does not exist.")
+}
+
+// IsKeyNotFound returns true if the error code is ErrorCodeKeyNotFound.
+func IsKeyNotFound(err error) bool {
+ if cErr, ok := err.(Error); ok {
+ return cErr.Code == ErrorCodeKeyNotFound
+ }
+ return false
+}
+
+// IsRoleNotFound returns true if the error means role not found of v2 API.
+func IsRoleNotFound(err error) bool {
+ if ae, ok := err.(authError); ok {
+ return roleNotFoundRegExp.MatchString(ae.Message)
+ }
+ return false
+}
+
+// IsUserNotFound returns true if the error means user not found of v2 API.
+func IsUserNotFound(err error) bool {
+ if ae, ok := err.(authError); ok {
+ return userNotFoundRegExp.MatchString(ae.Message)
+ }
+ return false
+}