etcdv3 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: rpc.proto for package 'etcdserverpb'
3
+ require_relative 'rpc_pb'
4
+
5
+ module Etcdserverpb
6
+ module KV
7
+ class Service
8
+
9
+ include GRPC::GenericService
10
+
11
+ self.marshal_class_method = :encode
12
+ self.unmarshal_class_method = :decode
13
+ self.service_name = 'etcdserverpb.KV'
14
+
15
+ # Range gets the keys in the range from the key-value store.
16
+ rpc :Range, RangeRequest, RangeResponse
17
+ # Put puts the given key into the key-value store.
18
+ # A put request increments the revision of the key-value store
19
+ # and generates one event in the event history.
20
+ rpc :Put, PutRequest, PutResponse
21
+ # DeleteRange deletes the given range from the key-value store.
22
+ # A delete request increments the revision of the key-value store
23
+ # and generates a delete event in the event history for every deleted key.
24
+ rpc :DeleteRange, DeleteRangeRequest, DeleteRangeResponse
25
+ # Txn processes multiple requests in a single transaction.
26
+ # A txn request increments the revision of the key-value store
27
+ # and generates events with the same revision for every completed request.
28
+ # It is not allowed to modify the same key several times within one txn.
29
+ rpc :Txn, TxnRequest, TxnResponse
30
+ # Compact compacts the event history in the etcd key-value store. The key-value
31
+ # store should be periodically compacted or the event history will continue to grow
32
+ # indefinitely.
33
+ rpc :Compact, CompactionRequest, CompactionResponse
34
+ end
35
+
36
+ Stub = Service.rpc_stub_class
37
+ end
38
+ module Watch
39
+ class Service
40
+
41
+ include GRPC::GenericService
42
+
43
+ self.marshal_class_method = :encode
44
+ self.unmarshal_class_method = :decode
45
+ self.service_name = 'etcdserverpb.Watch'
46
+
47
+ # Watch watches for events happening or that have happened. Both input and output
48
+ # are streams; the input stream is for creating and canceling watchers and the output
49
+ # stream sends events. One watch RPC can watch on multiple key ranges, streaming events
50
+ # for several watches at once. The entire event history can be watched starting from the
51
+ # last compaction revision.
52
+ rpc :Watch, stream(WatchRequest), stream(WatchResponse)
53
+ end
54
+
55
+ Stub = Service.rpc_stub_class
56
+ end
57
+ module Lease
58
+ class Service
59
+
60
+ include GRPC::GenericService
61
+
62
+ self.marshal_class_method = :encode
63
+ self.unmarshal_class_method = :decode
64
+ self.service_name = 'etcdserverpb.Lease'
65
+
66
+ # LeaseGrant creates a lease which expires if the server does not receive a keepAlive
67
+ # within a given time to live period. All keys attached to the lease will be expired and
68
+ # deleted if the lease expires. Each expired key generates a delete event in the event history.
69
+ rpc :LeaseGrant, LeaseGrantRequest, LeaseGrantResponse
70
+ # LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
71
+ rpc :LeaseRevoke, LeaseRevokeRequest, LeaseRevokeResponse
72
+ # LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
73
+ # to the server and streaming keep alive responses from the server to the client.
74
+ rpc :LeaseKeepAlive, stream(LeaseKeepAliveRequest), stream(LeaseKeepAliveResponse)
75
+ # LeaseTimeToLive retrieves lease information.
76
+ rpc :LeaseTimeToLive, LeaseTimeToLiveRequest, LeaseTimeToLiveResponse
77
+ end
78
+
79
+ Stub = Service.rpc_stub_class
80
+ end
81
+ module Cluster
82
+ class Service
83
+
84
+ include GRPC::GenericService
85
+
86
+ self.marshal_class_method = :encode
87
+ self.unmarshal_class_method = :decode
88
+ self.service_name = 'etcdserverpb.Cluster'
89
+
90
+ # MemberAdd adds a member into the cluster.
91
+ rpc :MemberAdd, MemberAddRequest, MemberAddResponse
92
+ # MemberRemove removes an existing member from the cluster.
93
+ rpc :MemberRemove, MemberRemoveRequest, MemberRemoveResponse
94
+ # MemberUpdate updates the member configuration.
95
+ rpc :MemberUpdate, MemberUpdateRequest, MemberUpdateResponse
96
+ # MemberList lists all the members in the cluster.
97
+ rpc :MemberList, MemberListRequest, MemberListResponse
98
+ end
99
+
100
+ Stub = Service.rpc_stub_class
101
+ end
102
+ module Maintenance
103
+ class Service
104
+
105
+ include GRPC::GenericService
106
+
107
+ self.marshal_class_method = :encode
108
+ self.unmarshal_class_method = :decode
109
+ self.service_name = 'etcdserverpb.Maintenance'
110
+
111
+ # Alarm activates, deactivates, and queries alarms regarding cluster health.
112
+ rpc :Alarm, AlarmRequest, AlarmResponse
113
+ # Status gets the status of the member.
114
+ rpc :Status, StatusRequest, StatusResponse
115
+ # Defragment defragments a member's backend database to recover storage space.
116
+ rpc :Defragment, DefragmentRequest, DefragmentResponse
117
+ # Hash returns the hash of the local KV state for consistency checking purpose.
118
+ # This is designed for testing; do not use this in production when there
119
+ # are ongoing transactions.
120
+ rpc :Hash, HashRequest, HashResponse
121
+ # Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
122
+ rpc :Snapshot, SnapshotRequest, stream(SnapshotResponse)
123
+ end
124
+
125
+ Stub = Service.rpc_stub_class
126
+ end
127
+ module Auth
128
+ class Service
129
+
130
+ include GRPC::GenericService
131
+
132
+ self.marshal_class_method = :encode
133
+ self.unmarshal_class_method = :decode
134
+ self.service_name = 'etcdserverpb.Auth'
135
+
136
+ # AuthEnable enables authentication.
137
+ rpc :AuthEnable, AuthEnableRequest, AuthEnableResponse
138
+ # AuthDisable disables authentication.
139
+ rpc :AuthDisable, AuthDisableRequest, AuthDisableResponse
140
+ # Authenticate processes an authenticate request.
141
+ rpc :Authenticate, AuthenticateRequest, AuthenticateResponse
142
+ # UserAdd adds a new user.
143
+ rpc :UserAdd, AuthUserAddRequest, AuthUserAddResponse
144
+ # UserGet gets detailed user information.
145
+ rpc :UserGet, AuthUserGetRequest, AuthUserGetResponse
146
+ # UserList gets a list of all users.
147
+ rpc :UserList, AuthUserListRequest, AuthUserListResponse
148
+ # UserDelete deletes a specified user.
149
+ rpc :UserDelete, AuthUserDeleteRequest, AuthUserDeleteResponse
150
+ # UserChangePassword changes the password of a specified user.
151
+ rpc :UserChangePassword, AuthUserChangePasswordRequest, AuthUserChangePasswordResponse
152
+ # UserGrant grants a role to a specified user.
153
+ rpc :UserGrantRole, AuthUserGrantRoleRequest, AuthUserGrantRoleResponse
154
+ # UserRevokeRole revokes a role of specified user.
155
+ rpc :UserRevokeRole, AuthUserRevokeRoleRequest, AuthUserRevokeRoleResponse
156
+ # RoleAdd adds a new role.
157
+ rpc :RoleAdd, AuthRoleAddRequest, AuthRoleAddResponse
158
+ # RoleGet gets detailed role information.
159
+ rpc :RoleGet, AuthRoleGetRequest, AuthRoleGetResponse
160
+ # RoleList gets lists of all roles.
161
+ rpc :RoleList, AuthRoleListRequest, AuthRoleListResponse
162
+ # RoleDelete deletes a specified role.
163
+ rpc :RoleDelete, AuthRoleDeleteRequest, AuthRoleDeleteResponse
164
+ # RoleGrantPermission grants a permission of a specified key or range to a specified role.
165
+ rpc :RoleGrantPermission, AuthRoleGrantPermissionRequest, AuthRoleGrantPermissionResponse
166
+ # RoleRevokePermission revokes a key or range permission of a specified role.
167
+ rpc :RoleRevokePermission, AuthRoleRevokePermissionRequest, AuthRoleRevokePermissionResponse
168
+ end
169
+
170
+ Stub = Service.rpc_stub_class
171
+ end
172
+ end
data/lib/etcdv3/kv.rb ADDED
@@ -0,0 +1,21 @@
1
+
2
+ class Etcd
3
+ class KV
4
+
5
+ def initialize(hostname, port, credentials)
6
+ @stub = Etcdserverpb::KV::Stub.new("#{hostname}:#{port}", credentials)
7
+ end
8
+
9
+ def put(key, value, metadata)
10
+ kv = Etcdserverpb::PutRequest.new(key: key, value: value)
11
+ @stub.put(kv, metadata: metadata)
12
+ end
13
+
14
+ def range(key, range_end, metadata)
15
+ kv = Etcdserverpb::RangeRequest.new(key: key, range_end: range_end)
16
+ result = @stub.range(kv, metadata: metadata)
17
+ result.kvs
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ // Copyright (c) 2015, Google Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package google.api;
18
+
19
+ import "http.proto";
20
+ import "descriptor.proto";
21
+
22
+ option java_multiple_files = true;
23
+ option java_outer_classname = "AnnotationsProto";
24
+ option java_package = "com.google.api";
25
+ option objc_class_prefix = "GAPI";
26
+
27
+ extend google.protobuf.MethodOptions {
28
+ // See `HttpRule`.
29
+ HttpRule http = 72295728;
30
+ }
@@ -0,0 +1,37 @@
1
+ syntax = "proto3";
2
+ package authpb;
3
+
4
+ import "gogo.proto";
5
+
6
+ option (gogoproto.marshaler_all) = true;
7
+ option (gogoproto.sizer_all) = true;
8
+ option (gogoproto.unmarshaler_all) = true;
9
+ option (gogoproto.goproto_getters_all) = false;
10
+ option (gogoproto.goproto_enum_prefix_all) = false;
11
+
12
+ // User is a single entry in the bucket authUsers
13
+ message User {
14
+ bytes name = 1;
15
+ bytes password = 2;
16
+ repeated string roles = 3;
17
+ }
18
+
19
+ // Permission is a single entity
20
+ message Permission {
21
+ enum Type {
22
+ READ = 0;
23
+ WRITE = 1;
24
+ READWRITE = 2;
25
+ }
26
+ Type permType = 1;
27
+
28
+ bytes key = 2;
29
+ bytes range_end = 3;
30
+ }
31
+
32
+ // Role is a single entry in the bucket authRoles
33
+ message Role {
34
+ bytes name = 1;
35
+
36
+ repeated Permission keyPermission = 2;
37
+ }