statelydb 0.15.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +202 -0
- data/README.md +2 -9
- data/lib/api/db/put_pb.rb +1 -1
- data/lib/common/auth/auth_token_provider.rb +21 -41
- data/lib/common/auth/token_fetcher.rb +3 -39
- data/lib/error.rb +5 -2
- data/lib/key_path.rb +1 -1
- data/lib/statelydb.rb +21 -8
- data/lib/transaction/transaction.rb +11 -2
- data/sig/statelydb.rbi +26 -78
- data/sig/statelydb.rbs +20 -63
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f23ab192f6828001354306b8ad34133ec3d2ffd190b984317b21cdd37f13260
|
4
|
+
data.tar.gz: 4748c4cb64afcec1ae6855b13eb77431686c5969519676ba76b312e13af328c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0fa966836be47eaa591ab5d88b10107471a28b0d4b05f4fb34d655a14826ae77f11bcf45096eb40c9c90acfdf4aba8b1c78cc849340fae79afd230608635812
|
7
|
+
data.tar.gz: 5911f73934190cbd9bdb415241f332bd740a4e073bbde7b2bb5f4a7fc8e91fcaccf18f246a3633be8d4401065f777a75a88243f8126b628163737b2f5bb3e070
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright 2024 Stately Cloud, Inc.
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -8,13 +8,6 @@ This is the Ruby SDK for [StatelyDB](https://stately.cloud).
|
|
8
8
|
|
9
9
|
We're still in an invite-only preview mode - if you're interested, please reach out to [preview@stately.cloud](mailto:preview@stately.cloud?subject=Early%20Access%20Program).
|
10
10
|
|
11
|
-
When you join the preview program, we'll set you up with a few bits of information:
|
12
|
-
|
13
|
-
1. `STATELY_CLIENT_ID` - a client identifier so we know what client you are.
|
14
|
-
2. `STATELY_CLIENT_SECRET` - a sensitive secret that lets your applications authenticate with the API.
|
15
|
-
3. A store ID that identifies which store in your organization you're using.
|
16
|
-
4. Access to our in-depth [Getting Started Guide].
|
17
|
-
|
18
11
|
Begin by following our [Getting Started Guide] which will help you define, generate, and publish a DB schema so that it can be used.
|
19
12
|
|
20
13
|
##### Install the SDK
|
@@ -32,8 +25,8 @@ Create an authenticated client, then import your item types from your generated
|
|
32
25
|
require_relative 'schema/stately'
|
33
26
|
|
34
27
|
def put_my_item
|
35
|
-
# Create a client. This will use the environment
|
36
|
-
#
|
28
|
+
# Create a client. This will use the environment variable
|
29
|
+
# STATELY_ACCESS_KEY to read your access key
|
37
30
|
client = StatelyDB::Client.new(store_id: <my-store-id>)
|
38
31
|
|
39
32
|
# Instantiate an item from your schema
|
data/lib/api/db/put_pb.rb
CHANGED
@@ -7,7 +7,7 @@ require 'google/protobuf'
|
|
7
7
|
require 'api/db/item_pb'
|
8
8
|
|
9
9
|
|
10
|
-
descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"|\n\nPutRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\'\n\x04puts\x18\x02 \x03(\x0b\x32\x13.stately.db.PutItemR\x04puts\x12*\n\x11schema_version_id\x18\x03 \x01(\rR\x0fschemaVersionId\"
|
10
|
+
descriptor_data = "\n\x0c\x64\x62/put.proto\x12\nstately.db\x1a\rdb/item.proto\"|\n\nPutRequest\x12\x19\n\x08store_id\x18\x01 \x01(\x04R\x07storeId\x12\'\n\x04puts\x18\x02 \x03(\x0b\x32\x13.stately.db.PutItemR\x04puts\x12*\n\x11schema_version_id\x18\x03 \x01(\rR\x0fschemaVersionId\"\x99\x01\n\x07PutItem\x12$\n\x04item\x18\x01 \x01(\x0b\x32\x10.stately.db.ItemR\x04item\x12\x42\n\x1doverwrite_metadata_timestamps\x18\x02 \x01(\x08R\x1boverwriteMetadataTimestamps\x12$\n\x0emust_not_exist\x18\x03 \x01(\x08R\x0cmustNotExist\"5\n\x0bPutResponse\x12&\n\x05items\x18\x01 \x03(\x0b\x32\x10.stately.db.ItemR\x05itemsBc\n\x0e\x63om.stately.dbB\x08PutProtoP\x01\xa2\x02\x03SDX\xaa\x02\nStately.Db\xca\x02\nStately\\Db\xe2\x02\x16Stately\\Db\\GPBMetadata\xea\x02\x0bStately::Dbb\x06proto3"
|
11
11
|
|
12
12
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
13
|
pool.add_serialized_file(descriptor_data)
|
@@ -13,36 +13,27 @@ require_relative "../../error"
|
|
13
13
|
|
14
14
|
LOGGER = Logger.new($stdout)
|
15
15
|
LOGGER.level = Logger::WARN
|
16
|
-
DEFAULT_GRANT_TYPE = "client_credentials"
|
17
16
|
|
18
17
|
# A module for Stately Cloud auth code
|
19
18
|
module StatelyDB
|
20
19
|
module Common
|
21
20
|
# A module for Stately Cloud auth code
|
22
21
|
module Auth
|
23
|
-
#
|
24
|
-
# which vends tokens from
|
25
|
-
# It will default to using the
|
26
|
-
# no credentials are explicitly passed and will throw an error if
|
22
|
+
# AuthTokenProvider is an implementation of the TokenProvider abstract base class
|
23
|
+
# which vends tokens from the StatelyDB auth API.
|
24
|
+
# It will default to using the value of `STATELY_ACCESS_KEY` if
|
25
|
+
# no credentials are explicitly passed and will throw an error if no credentials are found.
|
27
26
|
class AuthTokenProvider < TokenProvider
|
28
|
-
# @param [String]
|
29
|
-
# @param [String] audience The OAuth Audience for the token
|
30
|
-
# @param [String] client_secret The StatelyDB client secret credential
|
31
|
-
# @param [String] client_id The StatelyDB client ID credential
|
27
|
+
# @param [String] endpoint The endpoint of the auth server
|
32
28
|
# @param [String] access_key The StatelyDB access key credential
|
33
29
|
# @param [Float] base_retry_backoff_secs The base retry backoff in seconds
|
34
30
|
def initialize(
|
35
|
-
|
36
|
-
audience: "api.stately.cloud",
|
37
|
-
client_secret: ENV.fetch("STATELY_CLIENT_SECRET", nil),
|
38
|
-
client_id: ENV.fetch("STATELY_CLIENT_ID", nil),
|
31
|
+
endpoint: "https://api.stately.cloud",
|
39
32
|
access_key: ENV.fetch("STATELY_ACCESS_KEY", nil),
|
40
33
|
base_retry_backoff_secs: 1
|
41
34
|
)
|
42
35
|
super()
|
43
|
-
@actor = Async::Actor.new(Actor.new(
|
44
|
-
client_secret: client_secret, client_id: client_id, access_key: access_key,
|
45
|
-
base_retry_backoff_secs: base_retry_backoff_secs))
|
36
|
+
@actor = Async::Actor.new(Actor.new(endpoint:, access_key:, base_retry_backoff_secs:))
|
46
37
|
# this initialization cannot happen in the constructor because it is async and must run on the event loop
|
47
38
|
# which is not available in the constructor
|
48
39
|
@actor.init
|
@@ -63,38 +54,27 @@ module StatelyDB
|
|
63
54
|
# Actor for managing the token refresh
|
64
55
|
# This is designed to be used with Async::Actor and run on a dedicated thread.
|
65
56
|
class Actor
|
66
|
-
# @param [String]
|
67
|
-
# @param [String] audience The OAuth Audience for the token
|
68
|
-
# @param [String] client_secret The StatelyDB client secret credential
|
69
|
-
# @param [String] client_id The StatelyDB client ID credential
|
57
|
+
# @param [String] endpoint The endpoint of the OAuth server
|
70
58
|
# @param [String] access_key The StatelyDB access key credential
|
71
59
|
# @param [Float] base_retry_backoff_secs The base retry backoff in seconds
|
72
|
-
def initialize(
|
73
|
-
origin:,
|
74
|
-
audience:,
|
75
|
-
client_secret:,
|
76
|
-
client_id:,
|
77
|
-
access_key:,
|
78
|
-
base_retry_backoff_secs:
|
79
|
-
)
|
60
|
+
def initialize(endpoint:, access_key:, base_retry_backoff_secs:)
|
80
61
|
super()
|
81
62
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
63
|
+
if access_key.nil?
|
64
|
+
raise StatelyDB::Error.new(
|
65
|
+
"Unable to find an access key in the STATELY_ACCESS_KEY " \
|
66
|
+
"environment variable. Either pass your credentials in " \
|
67
|
+
"the options when creating a client or set this environment variable.",
|
68
|
+
code: GRPC::Core::StatusCodes::UNAUTHENTICATED,
|
69
|
+
stately_code: "Unauthenticated"
|
86
70
|
)
|
87
|
-
elsif !client_secret.nil? && !client_id.nil?
|
88
|
-
@token_fetcher = StatelyDB::Common::Auth::Auth0TokenFetcher.new(origin: origin, audience: audience,
|
89
|
-
client_secret: client_secret, client_id: client_id)
|
90
|
-
else
|
91
|
-
raise StatelyDB::Error.new("unable to find client credentials in STATELY_ACCESS_KEY or STATELY_CLIENT_ID and " \
|
92
|
-
"STATELY_CLIENT_SECRET environment variables. Either pass your credentials in " \
|
93
|
-
"explicitly or set these environment variables",
|
94
|
-
code: GRPC::Core::StatusCodes::UNAUTHENTICATED,
|
95
|
-
stately_code: "Unauthenticated")
|
96
71
|
end
|
97
72
|
|
73
|
+
@token_fetcher = StatelyDB::Common::Auth::StatelyAccessTokenFetcher.new(
|
74
|
+
endpoint: endpoint,
|
75
|
+
access_key: access_key,
|
76
|
+
base_retry_backoff_secs: base_retry_backoff_secs
|
77
|
+
)
|
98
78
|
@token_state = nil
|
99
79
|
@pending_refresh = nil
|
100
80
|
end
|
@@ -37,42 +37,6 @@ module StatelyDB
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
# Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
|
41
|
-
class Auth0TokenFetcher < TokenFetcher
|
42
|
-
# @param [String] origin The origin of the OAuth server
|
43
|
-
# @param [String] audience The OAuth Audience for the token
|
44
|
-
# @param [String] client_secret The StatelyDB client secret credential
|
45
|
-
# @param [String] client_id The StatelyDB client ID credential
|
46
|
-
def initialize(origin:, audience:, client_secret:, client_id:)
|
47
|
-
super()
|
48
|
-
@client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse(origin))
|
49
|
-
@audience = audience
|
50
|
-
@client_secret = client_secret
|
51
|
-
@client_id = client_id
|
52
|
-
end
|
53
|
-
|
54
|
-
# Fetch a new token from auth0
|
55
|
-
# @return [TokenResult] The fetched TokenResult
|
56
|
-
def fetch
|
57
|
-
headers = [["content-type", "application/json"]]
|
58
|
-
body = JSON.dump({ "client_id" => @client_id, client_secret: @client_secret, audience: @audience,
|
59
|
-
grant_type: DEFAULT_GRANT_TYPE })
|
60
|
-
Sync do
|
61
|
-
response = @client.post("/oauth/token", headers, body)
|
62
|
-
raise "Auth request failed" if response.status != 200
|
63
|
-
|
64
|
-
resp_data = JSON.parse(response.read)
|
65
|
-
TokenResult.new(token: resp_data["access_token"], expires_in_secs: resp_data["expires_in"])
|
66
|
-
ensure
|
67
|
-
response&.close
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def close
|
72
|
-
@client&.close
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
40
|
# StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
|
77
41
|
class StatelyAccessTokenFetcher < TokenFetcher
|
78
42
|
NON_RETRYABLE_ERRORS = [
|
@@ -84,14 +48,14 @@ module StatelyDB
|
|
84
48
|
].freeze
|
85
49
|
RETRY_ATTEMPTS = 10
|
86
50
|
|
87
|
-
# @param [String]
|
51
|
+
# @param [String] endpoint The endpoint of the OAuth server
|
88
52
|
# @param [String] access_key The StatelyDB access key credential
|
89
53
|
# @param [Float] base_retry_backoff_secs The base backoff time in seconds
|
90
|
-
def initialize(
|
54
|
+
def initialize(endpoint:, access_key:, base_retry_backoff_secs:)
|
91
55
|
super()
|
92
56
|
@access_key = access_key
|
93
57
|
@base_retry_backoff_secs = base_retry_backoff_secs
|
94
|
-
@channel = Common::Net.new_channel(endpoint:
|
58
|
+
@channel = Common::Net.new_channel(endpoint:)
|
95
59
|
error_interceptor = Common::ErrorInterceptor.new
|
96
60
|
@stub = Stately::Auth::AuthService::Stub.new(nil, nil, channel_override: @channel,
|
97
61
|
interceptors: [error_interceptor])
|
data/lib/error.rb
CHANGED
@@ -41,9 +41,12 @@ module StatelyDB
|
|
41
41
|
raw_detail = status.details[0]
|
42
42
|
if raw_detail.type_url == "type.googleapis.com/stately.errors.StatelyErrorDetails"
|
43
43
|
error_details = Stately::Errors::StatelyErrorDetails.decode(raw_detail.value)
|
44
|
+
message = error_details.message
|
45
|
+
rid = error.metadata["st-rid"]
|
46
|
+
message = "#{message} (Request ID: #{rid})" unless rid.nil?
|
44
47
|
upstream_cause = error_details.upstream_cause.empty? ? nil : StandardError.new(error_details.upstream_cause) # rubocop:disable Metrics/BlockNesting
|
45
|
-
return new(
|
46
|
-
|
48
|
+
return new(message, code: error.code, stately_code: error_details.stately_code,
|
49
|
+
cause: upstream_cause)
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
data/lib/key_path.rb
CHANGED
data/lib/statelydb.rb
CHANGED
@@ -28,11 +28,14 @@ module StatelyDB
|
|
28
28
|
# @param token_provider [Common::Auth::TokenProvider] the token provider to use for authentication.
|
29
29
|
# @param endpoint [String] the endpoint to connect to.
|
30
30
|
# @param region [String] the region to connect to.
|
31
|
+
# @param no_auth [Boolean] Indicates that the client should not attempt to get
|
32
|
+
# an auth token. This is used when talking to the Stately BYOC Data Plane on localhost.
|
31
33
|
def initialize(store_id:,
|
32
34
|
schema:,
|
33
35
|
token_provider: Common::Auth::AuthTokenProvider.new,
|
34
36
|
endpoint: nil,
|
35
|
-
region: nil
|
37
|
+
region: nil,
|
38
|
+
no_auth: false)
|
36
39
|
if store_id.nil?
|
37
40
|
raise StatelyDB::Error.new("store_id is required",
|
38
41
|
code: GRPC::Core::StatusCodes::INVALID_ARGUMENT,
|
@@ -46,13 +49,14 @@ module StatelyDB
|
|
46
49
|
|
47
50
|
endpoint = self.class.make_endpoint(endpoint:, region:)
|
48
51
|
@channel = Common::Net.new_channel(endpoint:)
|
49
|
-
|
52
|
+
# Make sure to use the correct endpoint for the default token provider
|
53
|
+
@token_provider = token_provider || Common::Auth::AuthTokenProvider.new(endpoint:)
|
50
54
|
|
51
|
-
|
52
|
-
|
55
|
+
interceptors = [Common::ErrorInterceptor.new]
|
56
|
+
interceptors << Common::Auth::Interceptor.new(token_provider:) unless no_auth
|
53
57
|
|
54
|
-
@stub = Stately::Db::DatabaseService::Stub.new(nil, nil,
|
55
|
-
|
58
|
+
@stub = Stately::Db::DatabaseService::Stub.new(nil, nil,
|
59
|
+
channel_override: @channel, interceptors:)
|
56
60
|
@store_id = store_id.to_i
|
57
61
|
@schema = schema
|
58
62
|
@allow_stale = false
|
@@ -188,12 +192,20 @@ module StatelyDB
|
|
188
192
|
# `initialValue` field in its key, that initial value will automatically
|
189
193
|
# be chosen not to conflict with existing items, so this condition only
|
190
194
|
# applies to key paths that do not contain the `initialValue` field.
|
195
|
+
# @param overwrite_metadata_timestamps [Boolean] If set to true, the server will
|
196
|
+
# set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the
|
197
|
+
# current values in this item (assuming you've mapped them to a field using
|
198
|
+
# `fromMetadata`). Without this, those fields are always ignored and the
|
199
|
+
# server sets them to the appropriate times. This option can be useful when
|
200
|
+
# migrating data from another system.
|
191
201
|
# @return [StatelyDB::Item] the item that was stored
|
192
202
|
#
|
193
203
|
# @example client.data.put(my_item)
|
194
204
|
# @example client.data.put(my_item, must_not_exist: true)
|
195
|
-
def put(item,
|
196
|
-
|
205
|
+
def put(item,
|
206
|
+
must_not_exist: false,
|
207
|
+
overwrite_metadata_timestamps: false)
|
208
|
+
resp = put_batch({ item:, must_not_exist:, overwrite_metadata_timestamps: })
|
197
209
|
|
198
210
|
# Always return a single Item.
|
199
211
|
resp.first
|
@@ -215,6 +227,7 @@ module StatelyDB
|
|
215
227
|
item = input[:item]
|
216
228
|
Stately::Db::PutItem.new(
|
217
229
|
item: item.send("marshal_stately"),
|
230
|
+
overwrite_metadata_timestamps: input[:overwrite_metadata_timestamps],
|
218
231
|
must_not_exist: input[:must_not_exist]
|
219
232
|
)
|
220
233
|
else
|
@@ -233,6 +233,12 @@ module StatelyDB
|
|
233
233
|
# `initialValue` field in its key, that initial value will automatically
|
234
234
|
# be chosen not to conflict with existing items, so this condition only
|
235
235
|
# applies to key paths that do not contain the `initialValue` field.
|
236
|
+
# @param overwrite_metadata_timestamps [Boolean] If set to true, the server will
|
237
|
+
# set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the
|
238
|
+
# current values in this item (assuming you've mapped them to a field using
|
239
|
+
# `fromMetadata`). Without this, those fields are always ignored and the
|
240
|
+
# server sets them to the appropriate times. This option can be useful when
|
241
|
+
# migrating data from another system.
|
236
242
|
# @return [String, Integer] the id of the item
|
237
243
|
#
|
238
244
|
# @example
|
@@ -242,8 +248,10 @@ module StatelyDB
|
|
242
248
|
# results.puts.each do |result|
|
243
249
|
# puts result.key_path
|
244
250
|
# end
|
245
|
-
def put(item,
|
246
|
-
|
251
|
+
def put(item,
|
252
|
+
must_not_exist: false,
|
253
|
+
overwrite_metadata_timestamps: false)
|
254
|
+
resp = put_batch({ item:, must_not_exist:, overwrite_metadata_timestamps: })
|
247
255
|
resp.first
|
248
256
|
end
|
249
257
|
|
@@ -269,6 +277,7 @@ module StatelyDB
|
|
269
277
|
item = input[:item]
|
270
278
|
Stately::Db::PutItem.new(
|
271
279
|
item: item.send("marshal_stately"),
|
280
|
+
overwrite_metadata_timestamps: input[:overwrite_metadata_timestamps],
|
272
281
|
must_not_exist: input[:must_not_exist]
|
273
282
|
)
|
274
283
|
else
|
data/sig/statelydb.rbi
CHANGED
@@ -204,16 +204,19 @@ module StatelyDB
|
|
204
204
|
# _@param_ `endpoint` — the endpoint to connect to.
|
205
205
|
#
|
206
206
|
# _@param_ `region` — the region to connect to.
|
207
|
+
#
|
208
|
+
# _@param_ `no_auth` — Indicates that the client should not attempt to get an auth token. This is used when talking to the Stately BYOC Data Plane on localhost.
|
207
209
|
sig do
|
208
210
|
params(
|
209
211
|
store_id: Integer,
|
210
212
|
schema: Module,
|
211
213
|
token_provider: Common::Auth::TokenProvider,
|
212
214
|
endpoint: T.nilable(String),
|
213
|
-
region: T.nilable(String)
|
215
|
+
region: T.nilable(String),
|
216
|
+
no_auth: T::Boolean
|
214
217
|
).void
|
215
218
|
end
|
216
|
-
def initialize(store_id:, schema:, token_provider: Common::Auth::AuthTokenProvider.new, endpoint: nil, region: nil); end
|
219
|
+
def initialize(store_id:, schema:, token_provider: Common::Auth::AuthTokenProvider.new, endpoint: nil, region: nil, no_auth: false); end
|
217
220
|
|
218
221
|
# _@return_ — nil
|
219
222
|
sig { void }
|
@@ -313,6 +316,8 @@ module StatelyDB
|
|
313
316
|
#
|
314
317
|
# _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
|
315
318
|
#
|
319
|
+
# _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
|
320
|
+
#
|
316
321
|
# _@return_ — the item that was stored
|
317
322
|
#
|
318
323
|
# client.data.put(my_item)
|
@@ -322,8 +327,8 @@ module StatelyDB
|
|
322
327
|
# client.data.put(my_item, must_not_exist: true)
|
323
328
|
# ```ruby
|
324
329
|
# ```
|
325
|
-
sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean).returns(StatelyDB::Item) }
|
326
|
-
def put(item, must_not_exist: false); end
|
330
|
+
sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean, overwrite_metadata_timestamps: T::Boolean).returns(StatelyDB::Item) }
|
331
|
+
def put(item, must_not_exist: false, overwrite_metadata_timestamps: false); end
|
327
332
|
|
328
333
|
# Put a batch of up to 50 Items into a StatelyDB Store.
|
329
334
|
#
|
@@ -605,35 +610,6 @@ module StatelyDB
|
|
605
610
|
def close; end
|
606
611
|
end
|
607
612
|
|
608
|
-
# Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
|
609
|
-
class Auth0TokenFetcher < StatelyDB::Common::Auth::TokenFetcher
|
610
|
-
# _@param_ `origin` — The origin of the OAuth server
|
611
|
-
#
|
612
|
-
# _@param_ `audience` — The OAuth Audience for the token
|
613
|
-
#
|
614
|
-
# _@param_ `client_secret` — The StatelyDB client secret credential
|
615
|
-
#
|
616
|
-
# _@param_ `client_id` — The StatelyDB client ID credential
|
617
|
-
sig do
|
618
|
-
params(
|
619
|
-
origin: String,
|
620
|
-
audience: String,
|
621
|
-
client_secret: String,
|
622
|
-
client_id: String
|
623
|
-
).void
|
624
|
-
end
|
625
|
-
def initialize(origin:, audience:, client_secret:, client_id:); end
|
626
|
-
|
627
|
-
# Fetch a new token from auth0
|
628
|
-
#
|
629
|
-
# _@return_ — The fetched TokenResult
|
630
|
-
sig { returns(TokenResult) }
|
631
|
-
def fetch; end
|
632
|
-
|
633
|
-
sig { returns(T.untyped) }
|
634
|
-
def close; end
|
635
|
-
end
|
636
|
-
|
637
613
|
# StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
|
638
614
|
class StatelyAccessTokenFetcher < StatelyDB::Common::Auth::TokenFetcher
|
639
615
|
NON_RETRYABLE_ERRORS = T.let([
|
@@ -645,13 +621,13 @@ module StatelyDB
|
|
645
621
|
].freeze, T.untyped)
|
646
622
|
RETRY_ATTEMPTS = T.let(10, T.untyped)
|
647
623
|
|
648
|
-
# _@param_ `
|
624
|
+
# _@param_ `endpoint` — The endpoint of the OAuth server
|
649
625
|
#
|
650
626
|
# _@param_ `access_key` — The StatelyDB access key credential
|
651
627
|
#
|
652
628
|
# _@param_ `base_retry_backoff_secs` — The base backoff time in seconds
|
653
|
-
sig { params(
|
654
|
-
def initialize(
|
629
|
+
sig { params(endpoint: String, access_key: String, base_retry_backoff_secs: Float).void }
|
630
|
+
def initialize(endpoint:, access_key:, base_retry_backoff_secs:); end
|
655
631
|
|
656
632
|
# Fetch a new token from the StatelyDB API
|
657
633
|
#
|
@@ -687,33 +663,18 @@ module StatelyDB
|
|
687
663
|
def close; end
|
688
664
|
end
|
689
665
|
|
690
|
-
#
|
691
|
-
# which vends tokens from
|
692
|
-
# It will default to using the
|
693
|
-
# no credentials are explicitly passed and will throw an error if
|
666
|
+
# AuthTokenProvider is an implementation of the TokenProvider abstract base class
|
667
|
+
# which vends tokens from the StatelyDB auth API.
|
668
|
+
# It will default to using the value of `STATELY_ACCESS_KEY` if
|
669
|
+
# no credentials are explicitly passed and will throw an error if no credentials are found.
|
694
670
|
class AuthTokenProvider < StatelyDB::Common::Auth::TokenProvider
|
695
|
-
# _@param_ `
|
696
|
-
#
|
697
|
-
# _@param_ `audience` — The OAuth Audience for the token
|
698
|
-
#
|
699
|
-
# _@param_ `client_secret` — The StatelyDB client secret credential
|
700
|
-
#
|
701
|
-
# _@param_ `client_id` — The StatelyDB client ID credential
|
671
|
+
# _@param_ `endpoint` — The endpoint of the auth server
|
702
672
|
#
|
703
673
|
# _@param_ `access_key` — The StatelyDB access key credential
|
704
674
|
#
|
705
675
|
# _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
|
706
|
-
sig
|
707
|
-
|
708
|
-
origin: String,
|
709
|
-
audience: String,
|
710
|
-
client_secret: String,
|
711
|
-
client_id: String,
|
712
|
-
access_key: String,
|
713
|
-
base_retry_backoff_secs: Float
|
714
|
-
).void
|
715
|
-
end
|
716
|
-
def initialize(origin: "https://oauth.stately.cloud", audience: "api.stately.cloud", client_secret: ENV.fetch("STATELY_CLIENT_SECRET", nil), client_id: ENV.fetch("STATELY_CLIENT_ID", nil), access_key: ENV.fetch("STATELY_ACCESS_KEY", nil), base_retry_backoff_secs: 1); end
|
676
|
+
sig { params(endpoint: String, access_key: String, base_retry_backoff_secs: Float).void }
|
677
|
+
def initialize(endpoint: "https://api.stately.cloud", access_key: ENV.fetch("STATELY_ACCESS_KEY", nil), base_retry_backoff_secs: 1); end
|
717
678
|
|
718
679
|
# Close the token provider and kill any background operations
|
719
680
|
# This just invokes the close method on the actor which should do the cleanup
|
@@ -729,28 +690,13 @@ module StatelyDB
|
|
729
690
|
# Actor for managing the token refresh
|
730
691
|
# This is designed to be used with Async::Actor and run on a dedicated thread.
|
731
692
|
class Actor
|
732
|
-
# _@param_ `
|
733
|
-
#
|
734
|
-
# _@param_ `audience` — The OAuth Audience for the token
|
735
|
-
#
|
736
|
-
# _@param_ `client_secret` — The StatelyDB client secret credential
|
737
|
-
#
|
738
|
-
# _@param_ `client_id` — The StatelyDB client ID credential
|
693
|
+
# _@param_ `endpoint` — The endpoint of the OAuth server
|
739
694
|
#
|
740
695
|
# _@param_ `access_key` — The StatelyDB access key credential
|
741
696
|
#
|
742
697
|
# _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
|
743
|
-
sig
|
744
|
-
|
745
|
-
origin: String,
|
746
|
-
audience: String,
|
747
|
-
client_secret: String,
|
748
|
-
client_id: String,
|
749
|
-
access_key: String,
|
750
|
-
base_retry_backoff_secs: Float
|
751
|
-
).void
|
752
|
-
end
|
753
|
-
def initialize(origin:, audience:, client_secret:, client_id:, access_key:, base_retry_backoff_secs:); end
|
698
|
+
sig { params(endpoint: String, access_key: String, base_retry_backoff_secs: Float).void }
|
699
|
+
def initialize(endpoint:, access_key:, base_retry_backoff_secs:); end
|
754
700
|
|
755
701
|
# Initialize the actor. This runs on the actor thread which means
|
756
702
|
# we can dispatch async operations here.
|
@@ -1000,6 +946,8 @@ module StatelyDB
|
|
1000
946
|
#
|
1001
947
|
# _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
|
1002
948
|
#
|
949
|
+
# _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
|
950
|
+
#
|
1003
951
|
# _@return_ — the id of the item
|
1004
952
|
#
|
1005
953
|
# ```ruby
|
@@ -1007,8 +955,8 @@ module StatelyDB
|
|
1007
955
|
# txn.put(my_item)
|
1008
956
|
# end
|
1009
957
|
# ```
|
1010
|
-
sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean).returns(T.any(String, Integer)) }
|
1011
|
-
def put(item, must_not_exist: false); end
|
958
|
+
sig { params(item: StatelyDB::Item, must_not_exist: T::Boolean, overwrite_metadata_timestamps: T::Boolean).returns(T.any(String, Integer)) }
|
959
|
+
def put(item, must_not_exist: false, overwrite_metadata_timestamps: false); end
|
1012
960
|
|
1013
961
|
# Put a batch of up to 50 Items into a StatelyDB Store. Results are not
|
1014
962
|
# returned until the transaction is committed and will be available in the
|
data/sig/statelydb.rbs
CHANGED
@@ -170,12 +170,15 @@ module StatelyDB
|
|
170
170
|
# _@param_ `endpoint` — the endpoint to connect to.
|
171
171
|
#
|
172
172
|
# _@param_ `region` — the region to connect to.
|
173
|
+
#
|
174
|
+
# _@param_ `no_auth` — Indicates that the client should not attempt to get an auth token. This is used when talking to the Stately BYOC Data Plane on localhost.
|
173
175
|
def initialize: (
|
174
176
|
store_id: Integer,
|
175
177
|
schema: Module,
|
176
178
|
?token_provider: Common::Auth::TokenProvider,
|
177
179
|
?endpoint: String?,
|
178
|
-
?region: String
|
180
|
+
?region: String?,
|
181
|
+
?no_auth: bool
|
179
182
|
) -> void
|
180
183
|
|
181
184
|
# _@return_ — nil
|
@@ -267,6 +270,8 @@ module StatelyDB
|
|
267
270
|
#
|
268
271
|
# _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
|
269
272
|
#
|
273
|
+
# _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
|
274
|
+
#
|
270
275
|
# _@return_ — the item that was stored
|
271
276
|
#
|
272
277
|
# client.data.put(my_item)
|
@@ -276,7 +281,7 @@ module StatelyDB
|
|
276
281
|
# client.data.put(my_item, must_not_exist: true)
|
277
282
|
# ```ruby
|
278
283
|
# ```
|
279
|
-
def put: (StatelyDB::Item item, ?must_not_exist: bool) -> StatelyDB::Item
|
284
|
+
def put: (StatelyDB::Item item, ?must_not_exist: bool, ?overwrite_metadata_timestamps: bool) -> StatelyDB::Item
|
280
285
|
|
281
286
|
# Put a batch of up to 50 Items into a StatelyDB Store.
|
282
287
|
#
|
@@ -524,41 +529,17 @@ module StatelyDB
|
|
524
529
|
def close: () -> untyped
|
525
530
|
end
|
526
531
|
|
527
|
-
# Auth0TokenFetcher is a TokenFetcher that fetches tokens from an Auth0 server
|
528
|
-
class Auth0TokenFetcher < StatelyDB::Common::Auth::TokenFetcher
|
529
|
-
# _@param_ `origin` — The origin of the OAuth server
|
530
|
-
#
|
531
|
-
# _@param_ `audience` — The OAuth Audience for the token
|
532
|
-
#
|
533
|
-
# _@param_ `client_secret` — The StatelyDB client secret credential
|
534
|
-
#
|
535
|
-
# _@param_ `client_id` — The StatelyDB client ID credential
|
536
|
-
def initialize: (
|
537
|
-
origin: String,
|
538
|
-
audience: String,
|
539
|
-
client_secret: String,
|
540
|
-
client_id: String
|
541
|
-
) -> void
|
542
|
-
|
543
|
-
# Fetch a new token from auth0
|
544
|
-
#
|
545
|
-
# _@return_ — The fetched TokenResult
|
546
|
-
def fetch: () -> TokenResult
|
547
|
-
|
548
|
-
def close: () -> untyped
|
549
|
-
end
|
550
|
-
|
551
532
|
# StatelyAccessTokenFetcher is a TokenFetcher that fetches tokens from the StatelyDB API
|
552
533
|
class StatelyAccessTokenFetcher < StatelyDB::Common::Auth::TokenFetcher
|
553
534
|
NON_RETRYABLE_ERRORS: untyped
|
554
535
|
RETRY_ATTEMPTS: untyped
|
555
536
|
|
556
|
-
# _@param_ `
|
537
|
+
# _@param_ `endpoint` — The endpoint of the OAuth server
|
557
538
|
#
|
558
539
|
# _@param_ `access_key` — The StatelyDB access key credential
|
559
540
|
#
|
560
541
|
# _@param_ `base_retry_backoff_secs` — The base backoff time in seconds
|
561
|
-
def initialize: (
|
542
|
+
def initialize: (endpoint: String, access_key: String, base_retry_backoff_secs: Float) -> void
|
562
543
|
|
563
544
|
# Fetch a new token from the StatelyDB API
|
564
545
|
#
|
@@ -589,30 +570,17 @@ module StatelyDB
|
|
589
570
|
def close: () -> untyped
|
590
571
|
end
|
591
572
|
|
592
|
-
#
|
593
|
-
# which vends tokens from
|
594
|
-
# It will default to using the
|
595
|
-
# no credentials are explicitly passed and will throw an error if
|
573
|
+
# AuthTokenProvider is an implementation of the TokenProvider abstract base class
|
574
|
+
# which vends tokens from the StatelyDB auth API.
|
575
|
+
# It will default to using the value of `STATELY_ACCESS_KEY` if
|
576
|
+
# no credentials are explicitly passed and will throw an error if no credentials are found.
|
596
577
|
class AuthTokenProvider < StatelyDB::Common::Auth::TokenProvider
|
597
|
-
# _@param_ `
|
598
|
-
#
|
599
|
-
# _@param_ `audience` — The OAuth Audience for the token
|
600
|
-
#
|
601
|
-
# _@param_ `client_secret` — The StatelyDB client secret credential
|
602
|
-
#
|
603
|
-
# _@param_ `client_id` — The StatelyDB client ID credential
|
578
|
+
# _@param_ `endpoint` — The endpoint of the auth server
|
604
579
|
#
|
605
580
|
# _@param_ `access_key` — The StatelyDB access key credential
|
606
581
|
#
|
607
582
|
# _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
|
608
|
-
def initialize: (
|
609
|
-
?origin: String,
|
610
|
-
?audience: String,
|
611
|
-
?client_secret: String,
|
612
|
-
?client_id: String,
|
613
|
-
?access_key: String,
|
614
|
-
?base_retry_backoff_secs: Float
|
615
|
-
) -> void
|
583
|
+
def initialize: (?endpoint: String, ?access_key: String, ?base_retry_backoff_secs: Float) -> void
|
616
584
|
|
617
585
|
# Close the token provider and kill any background operations
|
618
586
|
# This just invokes the close method on the actor which should do the cleanup
|
@@ -626,25 +594,12 @@ module StatelyDB
|
|
626
594
|
# Actor for managing the token refresh
|
627
595
|
# This is designed to be used with Async::Actor and run on a dedicated thread.
|
628
596
|
class Actor
|
629
|
-
# _@param_ `
|
630
|
-
#
|
631
|
-
# _@param_ `audience` — The OAuth Audience for the token
|
632
|
-
#
|
633
|
-
# _@param_ `client_secret` — The StatelyDB client secret credential
|
634
|
-
#
|
635
|
-
# _@param_ `client_id` — The StatelyDB client ID credential
|
597
|
+
# _@param_ `endpoint` — The endpoint of the OAuth server
|
636
598
|
#
|
637
599
|
# _@param_ `access_key` — The StatelyDB access key credential
|
638
600
|
#
|
639
601
|
# _@param_ `base_retry_backoff_secs` — The base retry backoff in seconds
|
640
|
-
def initialize: (
|
641
|
-
origin: String,
|
642
|
-
audience: String,
|
643
|
-
client_secret: String,
|
644
|
-
client_id: String,
|
645
|
-
access_key: String,
|
646
|
-
base_retry_backoff_secs: Float
|
647
|
-
) -> void
|
602
|
+
def initialize: (endpoint: String, access_key: String, base_retry_backoff_secs: Float) -> void
|
648
603
|
|
649
604
|
# Initialize the actor. This runs on the actor thread which means
|
650
605
|
# we can dispatch async operations here.
|
@@ -858,6 +813,8 @@ module StatelyDB
|
|
858
813
|
#
|
859
814
|
# _@param_ `must_not_exist` — A condition that indicates this item must not already exist at any of its key paths. If there is already an item at one of those paths, the Put operation will fail with a "ConditionalCheckFailed" error. Note that if the item has an `initialValue` field in its key, that initial value will automatically be chosen not to conflict with existing items, so this condition only applies to key paths that do not contain the `initialValue` field.
|
860
815
|
#
|
816
|
+
# _@param_ `overwrite_metadata_timestamps` — If set to true, the server will set the `createdAtTime` and/or `lastModifiedAtTime` fields based on the current values in this item (assuming you've mapped them to a field using `fromMetadata`). Without this, those fields are always ignored and the server sets them to the appropriate times. This option can be useful when migrating data from another system.
|
817
|
+
#
|
861
818
|
# _@return_ — the id of the item
|
862
819
|
#
|
863
820
|
# ```ruby
|
@@ -865,7 +822,7 @@ module StatelyDB
|
|
865
822
|
# txn.put(my_item)
|
866
823
|
# end
|
867
824
|
# ```
|
868
|
-
def put: (StatelyDB::Item item, ?must_not_exist: bool) -> (String | Integer)
|
825
|
+
def put: (StatelyDB::Item item, ?must_not_exist: bool, ?overwrite_metadata_timestamps: bool) -> (String | Integer)
|
869
826
|
|
870
827
|
# Put a batch of up to 50 Items into a StatelyDB Store. Results are not
|
871
828
|
# returned until the transaction is committed and will be available in the
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statelydb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stately Cloud, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -72,6 +72,7 @@ executables: []
|
|
72
72
|
extensions: []
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
|
+
- LICENSE.txt
|
75
76
|
- README.md
|
76
77
|
- lib/api/auth/get_auth_token_pb.rb
|
77
78
|
- lib/api/auth/service_pb.rb
|