envless-sdk 0.0.1
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +24 -0
- data/README.md +171 -0
- data/lib/envless/sdk/api_error.rb +54 -0
- data/lib/envless/sdk/bodies.rb +49 -0
- data/lib/envless/sdk/client.rb +39 -0
- data/lib/envless/sdk/clock.rb +24 -0
- data/lib/envless/sdk/connection_pool.rb +83 -0
- data/lib/envless/sdk/connector.rb +26 -0
- data/lib/envless/sdk/constants.rb +262 -0
- data/lib/envless/sdk/crypto/cipher.rb +58 -0
- data/lib/envless/sdk/crypto/codec.rb +23 -0
- data/lib/envless/sdk/crypto/envelope.rb +41 -0
- data/lib/envless/sdk/crypto/keys.rb +42 -0
- data/lib/envless/sdk/crypto/passphrase.rb +38 -0
- data/lib/envless/sdk/crypto/passphrase_rules.rb +42 -0
- data/lib/envless/sdk/crypto/values.rb +31 -0
- data/lib/envless/sdk/crypto/workspace_key.rb +40 -0
- data/lib/envless/sdk/crypto_messages.rb +31 -0
- data/lib/envless/sdk/default_client.rb +55 -0
- data/lib/envless/sdk/defaults.rb +32 -0
- data/lib/envless/sdk/envelope.rb +48 -0
- data/lib/envless/sdk/environment.rb +42 -0
- data/lib/envless/sdk/errors.rb +23 -0
- data/lib/envless/sdk/exchange.rb +27 -0
- data/lib/envless/sdk/helpers.rb +49 -0
- data/lib/envless/sdk/http.rb +46 -0
- data/lib/envless/sdk/listing.rb +54 -0
- data/lib/envless/sdk/messages.rb +43 -0
- data/lib/envless/sdk/net_http_adapter.rb +84 -0
- data/lib/envless/sdk/numbers.rb +44 -0
- data/lib/envless/sdk/options.rb +56 -0
- data/lib/envless/sdk/pagination.rb +31 -0
- data/lib/envless/sdk/paths.rb +70 -0
- data/lib/envless/sdk/received.rb +28 -0
- data/lib/envless/sdk/redirects.rb +56 -0
- data/lib/envless/sdk/resource.rb +50 -0
- data/lib/envless/sdk/resources/environments.rb +61 -0
- data/lib/envless/sdk/resources/invites.rb +28 -0
- data/lib/envless/sdk/resources/keys.rb +36 -0
- data/lib/envless/sdk/resources/me.rb +11 -0
- data/lib/envless/sdk/resources/members.rb +36 -0
- data/lib/envless/sdk/resources/product_access.rb +30 -0
- data/lib/envless/sdk/resources/products.rb +62 -0
- data/lib/envless/sdk/resources/projects.rb +42 -0
- data/lib/envless/sdk/resources/roles.rb +40 -0
- data/lib/envless/sdk/resources/variable_changes.rb +57 -0
- data/lib/envless/sdk/resources/variables.rb +49 -0
- data/lib/envless/sdk/resources/versions.rb +60 -0
- data/lib/envless/sdk/resources/webhook_deliveries.rb +33 -0
- data/lib/envless/sdk/resources/webhooks.rb +44 -0
- data/lib/envless/sdk/resources/workspace.rb +26 -0
- data/lib/envless/sdk/resources/workspace_domain.rb +31 -0
- data/lib/envless/sdk/resources/workspaces.rb +24 -0
- data/lib/envless/sdk/results.rb +43 -0
- data/lib/envless/sdk/retry_policy.rb +36 -0
- data/lib/envless/sdk/rotation/entry_rotator.rb +61 -0
- data/lib/envless/sdk/rotation/key_ring.rb +34 -0
- data/lib/envless/sdk/rotation/ledger.rb +36 -0
- data/lib/envless/sdk/rotation/runner.rb +45 -0
- data/lib/envless/sdk/rotation/variable_rotator.rb +38 -0
- data/lib/envless/sdk/text.rb +71 -0
- data/lib/envless/sdk/transport.rb +62 -0
- data/lib/envless/sdk/update_notice.rb +66 -0
- data/lib/envless/sdk/urls.rb +70 -0
- data/lib/envless/sdk/variable_names.rb +55 -0
- data/lib/envless/sdk/version.rb +5 -0
- data/lib/envless/sdk/webhooks/headers.rb +49 -0
- data/lib/envless/sdk/webhooks/verify.rb +58 -0
- data/lib/envless/sdk/wire.rb +77 -0
- data/lib/envless/sdk.rb +77 -0
- data/sig/envless/sdk/adapter.rbs +60 -0
- data/sig/envless/sdk/client.rbs +31 -0
- data/sig/envless/sdk/crypto.rbs +92 -0
- data/sig/envless/sdk/errors.rbs +37 -0
- data/sig/envless/sdk/http.rbs +31 -0
- data/sig/envless/sdk/pagination.rbs +81 -0
- data/sig/envless/sdk/results.rbs +62 -0
- data/sig/envless/sdk/rotation.rbs +86 -0
- data/sig/envless/sdk/settings.rbs +81 -0
- data/sig/envless/sdk/stdlib.rbs +8 -0
- data/sig/envless/sdk/text.rbs +52 -0
- data/sig/envless/sdk/transport.rbs +79 -0
- data/sig/envless/sdk/urls.rbs +73 -0
- data/sig/envless/sdk/webhooks.rbs +23 -0
- data/sig/envless/sdk.rbs +36 -0
- data/sig/generated/constants.rbs +57 -0
- data/sig/generated/resources.rbs +209 -0
- data/sig/generated/types.rbs +466 -0
- data/sig/manifest.yaml +3 -0
- metadata +134 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Redirects
|
|
5
|
+
STATUSES = [301, 302, 303, 307, 308].freeze
|
|
6
|
+
SAFE_METHODS = %w[GET HEAD].freeze
|
|
7
|
+
BODY_HEADERS = %w[content-type content-encoding content-language content-location].freeze
|
|
8
|
+
UNSAFE = %r{[^A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=%]}
|
|
9
|
+
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def follow(adapter, request, deadline)
|
|
13
|
+
current = request
|
|
14
|
+
|
|
15
|
+
(Defaults::MAX_REDIRECTS + 1).times do
|
|
16
|
+
response = HttpResponse.from(adapter.call(current.with(timeout: Clock.remaining(deadline))))
|
|
17
|
+
location = response.header(Defaults::LOCATION_HEADER)
|
|
18
|
+
return response unless STATUSES.include?(response.status) && location && !location.empty?
|
|
19
|
+
|
|
20
|
+
current = following(current, response.status, location)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
raise NetworkError, format(Messages::TOO_MANY_REDIRECTS, count: Defaults::MAX_REDIRECTS)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def following(request, status, location)
|
|
27
|
+
target = target_of(request.url, location)
|
|
28
|
+
|
|
29
|
+
method, body, headers = rewritten(request, status)
|
|
30
|
+
headers = headers.reject { |name, _| name.casecmp?(Constants::HEADER_KEYS[:AUTHORIZATION]) } unless same_origin?(request.url, target)
|
|
31
|
+
|
|
32
|
+
request.with(method:, url: target, headers:, body:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def target_of(base, location)
|
|
36
|
+
cleaned = Text.utf8(location).strip.delete("\t\n\r").tr("\\", "/")
|
|
37
|
+
encoded = cleaned.gsub(UNSAFE) { |character| character.bytes.map { |byte| format("%%%02X", byte) }.join }
|
|
38
|
+
target = URI.join(base, encoded)
|
|
39
|
+
raise NetworkError, Messages::REDIRECT_SCHEME unless target.is_a?(URI::HTTP) && !target.host.to_s.empty?
|
|
40
|
+
|
|
41
|
+
target.to_s
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def rewritten(request, status)
|
|
45
|
+
drop = (status == 303 && !SAFE_METHODS.include?(request.method)) || ([301, 302].include?(status) && request.method == "POST")
|
|
46
|
+
return [request.method, request.body, request.headers] unless drop
|
|
47
|
+
|
|
48
|
+
kept = request.headers.reject { |name, _| BODY_HEADERS.include?(name.downcase) }
|
|
49
|
+
[(request.method == "HEAD") ? "HEAD" : "GET", nil, kept]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def same_origin?(left, right)
|
|
53
|
+
Urls.origin(left) == Urls.origin(right)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
class Resource
|
|
5
|
+
include Constants
|
|
6
|
+
|
|
7
|
+
def initialize(transport)
|
|
8
|
+
@transport = transport
|
|
9
|
+
freeze
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def inspect
|
|
13
|
+
"#<#{self.class.name}>"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def request(path, method: HTTP_METHODS[:GET], query: nil, body: nil, timeout: nil)
|
|
19
|
+
@transport.request(path, method:, query:, body:, timeout:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def scoped(product)
|
|
23
|
+
{QUERY_KEYS[:PRODUCT] => product}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def page(path, collection, listing, timeout)
|
|
27
|
+
Pagination.fetch_page(@transport, path, collection, listing, timeout)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def all(path, collection, listing, timeout)
|
|
31
|
+
Pagination.collect_all(@transport, path, collection, listing, timeout)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def each_item(path, collection, listing, timeout, &block)
|
|
35
|
+
walk = Pagination.iterate(@transport, path, collection, listing, timeout)
|
|
36
|
+
return walk unless block
|
|
37
|
+
|
|
38
|
+
walk.each(&block)
|
|
39
|
+
nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def body_of(body, fields)
|
|
43
|
+
Bodies.merge(body, fields)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def list_of(values, name)
|
|
47
|
+
Bodies.list(values, name)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Environments < Resource
|
|
6
|
+
def list(project, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(Paths.environments_path(project), COLLECTIONS[:ENVIRONMENTS],
|
|
8
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_all(project, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
12
|
+
all(Paths.environments_path(project), COLLECTIONS[:ENVIRONMENTS],
|
|
13
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def iterate(project, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
17
|
+
each_item(Paths.environments_path(project), COLLECTIONS[:ENVIRONMENTS],
|
|
18
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get(project, environment, product: nil, timeout: nil)
|
|
22
|
+
request(Paths.environment_path(project, environment), query: scoped(product), timeout:)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create(project, body = nil, product: nil, timeout: nil, **fields)
|
|
26
|
+
request(Paths.environments_path(project), method: HTTP_METHODS[:POST], query: scoped(product),
|
|
27
|
+
body: body_of(body, fields), timeout:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update(project, environment, patch = nil, product: nil, timeout: nil, **fields)
|
|
31
|
+
request(Paths.environment_path(project, environment), method: HTTP_METHODS[:PATCH], query: scoped(product),
|
|
32
|
+
body: body_of(patch, fields), timeout:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def delete(project, environment, product: nil, timeout: nil)
|
|
36
|
+
request(Paths.environment_path(project, environment), method: HTTP_METHODS[:DELETE], query: scoped(product),
|
|
37
|
+
timeout:)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def duplicate(project, environment, product: nil, timeout: nil)
|
|
41
|
+
request("#{Paths.environment_path(project, environment)}/#{SEGMENTS[:DUPLICATE]}", method: HTTP_METHODS[:POST],
|
|
42
|
+
query: scoped(product), timeout:)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def expose(project, environment, product: nil, timeout: nil)
|
|
46
|
+
set_exposed(project, environment, true, product, timeout)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def unexpose(project, environment, product: nil, timeout: nil)
|
|
50
|
+
set_exposed(project, environment, false, product, timeout)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def set_exposed(project, environment, exposed, product, timeout)
|
|
56
|
+
request("#{Paths.environment_path(project, environment)}/#{SEGMENTS[:EXPOSE]}", method: HTTP_METHODS[:POST],
|
|
57
|
+
query: scoped(product), body: {"exposed" => exposed}, timeout:)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Invites < Resource
|
|
6
|
+
def list(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(PATHS[:INVITES], COLLECTIONS[:INVITES], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
11
|
+
all(PATHS[:INVITES], COLLECTIONS[:INVITES], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
15
|
+
each_item(PATHS[:INVITES], COLLECTIONS[:INVITES], Listing.of(limit:, offset:, search:, order:, product:),
|
|
16
|
+
timeout, &block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def revoke(id, timeout: nil)
|
|
20
|
+
request(Paths.invite_path(id), method: HTTP_METHODS[:DELETE], timeout:)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def resend(id, timeout: nil)
|
|
24
|
+
request("#{Paths.invite_path(id)}/#{SEGMENTS[:RESEND]}", method: HTTP_METHODS[:POST], timeout:)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Keys < Resource
|
|
6
|
+
def list(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(PATHS[:KEYS], COLLECTIONS[:KEYS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
11
|
+
all(PATHS[:KEYS], COLLECTIONS[:KEYS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
15
|
+
each_item(PATHS[:KEYS], COLLECTIONS[:KEYS], Listing.of(limit:, offset:, search:, order:, product:), timeout,
|
|
16
|
+
&block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get(id, timeout: nil)
|
|
20
|
+
request(Paths.key_path(id), timeout:)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create(body = nil, timeout: nil, **fields)
|
|
24
|
+
request(PATHS[:KEYS], method: HTTP_METHODS[:POST], body: body_of(body, fields), timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update(id, patch = nil, timeout: nil, **fields)
|
|
28
|
+
request(Paths.key_path(id), method: HTTP_METHODS[:PATCH], body: body_of(patch, fields), timeout:)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def delete(id, timeout: nil)
|
|
32
|
+
request(Paths.key_path(id), method: HTTP_METHODS[:DELETE], timeout:)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Members < Resource
|
|
6
|
+
def list(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(PATHS[:MEMBERS], COLLECTIONS[:MEMBERS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
11
|
+
all(PATHS[:MEMBERS], COLLECTIONS[:MEMBERS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
15
|
+
each_item(PATHS[:MEMBERS], COLLECTIONS[:MEMBERS], Listing.of(limit:, offset:, search:, order:, product:),
|
|
16
|
+
timeout, &block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def invite(body = nil, timeout: nil, **fields)
|
|
20
|
+
request(PATHS[:MEMBERS], method: HTTP_METHODS[:POST], body: body_of(body, fields), timeout:)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def update(id, patch = nil, timeout: nil, **fields)
|
|
24
|
+
request(Paths.member_path(id), method: HTTP_METHODS[:PATCH], body: body_of(patch, fields), timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def remove(id, timeout: nil)
|
|
28
|
+
request(Paths.member_path(id), method: HTTP_METHODS[:DELETE], timeout:)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def leave(timeout: nil)
|
|
32
|
+
request(PATHS[:MEMBERS_ME], method: HTTP_METHODS[:DELETE], timeout:)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class ProductAccess < Resource
|
|
6
|
+
def list(slug, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
query = Listing.of(limit:, offset:, search:, order:).query
|
|
8
|
+
Pages.access_page_of(request(Paths.product_access_path(slug), query:, timeout:), COLLECTIONS[:ACCESS])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_all(slug, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
12
|
+
all(Paths.product_access_path(slug), COLLECTIONS[:ACCESS], Listing.of(limit:, offset:, search:, order:, product:),
|
|
13
|
+
timeout)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def iterate(slug, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
17
|
+
each_item(Paths.product_access_path(slug), COLLECTIONS[:ACCESS],
|
|
18
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def grant(slug, member_id, timeout: nil)
|
|
22
|
+
request(Paths.product_access_member_path(slug, member_id), method: HTTP_METHODS[:PUT], timeout:)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def revoke(slug, member_id, timeout: nil)
|
|
26
|
+
request(Paths.product_access_member_path(slug, member_id), method: HTTP_METHODS[:DELETE], timeout:)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Products < Resource
|
|
6
|
+
attr_reader :access
|
|
7
|
+
|
|
8
|
+
def initialize(transport)
|
|
9
|
+
@access = ProductAccess.new(transport)
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def list(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
14
|
+
page(PATHS[:PRODUCTS], COLLECTIONS[:PRODUCTS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def list_all(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
18
|
+
all(PATHS[:PRODUCTS], COLLECTIONS[:PRODUCTS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def iterate(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
22
|
+
each_item(PATHS[:PRODUCTS], COLLECTIONS[:PRODUCTS], Listing.of(limit:, offset:, search:, order:, product:),
|
|
23
|
+
timeout, &block)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get(slug, timeout: nil)
|
|
27
|
+
request(Paths.product_path(slug), timeout:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def create(body = nil, timeout: nil, **fields)
|
|
31
|
+
request(PATHS[:PRODUCTS], method: HTTP_METHODS[:POST], body: body_of(body, fields), timeout:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update(slug, patch = nil, timeout: nil, **fields)
|
|
35
|
+
request(Paths.product_path(slug), method: HTTP_METHODS[:PATCH], body: body_of(patch, fields), timeout:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def delete(slug, timeout: nil)
|
|
39
|
+
request(Paths.product_path(slug), method: HTTP_METHODS[:DELETE], timeout:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def duplicate(slug, timeout: nil)
|
|
43
|
+
request("#{Paths.product_path(slug)}/#{SEGMENTS[:DUPLICATE]}", method: HTTP_METHODS[:POST], timeout:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def list_projects(slug, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
47
|
+
page(Paths.product_projects_path(slug), COLLECTIONS[:PROJECTS],
|
|
48
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def list_all_projects(slug, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
52
|
+
all(Paths.product_projects_path(slug), COLLECTIONS[:PROJECTS],
|
|
53
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def iterate_projects(slug, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
57
|
+
each_item(Paths.product_projects_path(slug), COLLECTIONS[:PROJECTS],
|
|
58
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Projects < Resource
|
|
6
|
+
def list(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(PATHS[:PROJECTS], COLLECTIONS[:PROJECTS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
11
|
+
all(PATHS[:PROJECTS], COLLECTIONS[:PROJECTS], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
15
|
+
each_item(PATHS[:PROJECTS], COLLECTIONS[:PROJECTS], Listing.of(limit:, offset:, search:, order:, product:),
|
|
16
|
+
timeout, &block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get(slug, product: nil, timeout: nil)
|
|
20
|
+
request(Paths.project_path(slug), query: scoped(product), timeout:)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create(body = nil, timeout: nil, **fields)
|
|
24
|
+
request(PATHS[:PROJECTS], method: HTTP_METHODS[:POST], body: body_of(body, fields), timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update(slug, patch = nil, product: nil, timeout: nil, **fields)
|
|
28
|
+
request(Paths.project_path(slug), method: HTTP_METHODS[:PATCH], query: scoped(product),
|
|
29
|
+
body: body_of(patch, fields), timeout:)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def delete(slug, product: nil, timeout: nil)
|
|
33
|
+
request(Paths.project_path(slug), method: HTTP_METHODS[:DELETE], query: scoped(product), timeout:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def duplicate(slug, product: nil, timeout: nil)
|
|
37
|
+
request("#{Paths.project_path(slug)}/#{SEGMENTS[:DUPLICATE]}", method: HTTP_METHODS[:POST],
|
|
38
|
+
query: scoped(product), timeout:)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Roles < Resource
|
|
6
|
+
def list(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(PATHS[:ROLES], COLLECTIONS[:ROLES], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
11
|
+
all(PATHS[:ROLES], COLLECTIONS[:ROLES], Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil, &block)
|
|
15
|
+
each_item(PATHS[:ROLES], COLLECTIONS[:ROLES], Listing.of(limit:, offset:, search:, order:, product:), timeout,
|
|
16
|
+
&block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get(id, timeout: nil)
|
|
20
|
+
request(Paths.role_path(id), timeout:)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create(body = nil, timeout: nil, **fields)
|
|
24
|
+
request(PATHS[:ROLES], method: HTTP_METHODS[:POST], body: body_of(body, fields), timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update(id, patch = nil, timeout: nil, **fields)
|
|
28
|
+
request(Paths.role_path(id), method: HTTP_METHODS[:PATCH], body: body_of(patch, fields), timeout:)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def delete(id, timeout: nil)
|
|
32
|
+
request(Paths.role_path(id), method: HTTP_METHODS[:DELETE], timeout:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def list_permissions(timeout: nil)
|
|
36
|
+
request(PATHS[:PERMISSIONS], timeout:)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Variables < Resource
|
|
6
|
+
def create(project, environment, body = nil, product: nil, timeout: nil, **fields)
|
|
7
|
+
payload = body_of(body, fields)
|
|
8
|
+
VariableNames.assert_input(payload)
|
|
9
|
+
request(Paths.variables_path(project, environment), method: HTTP_METHODS[:POST], query: scoped(product),
|
|
10
|
+
body: payload, timeout:)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def create_many(project, environment, items, product: nil, timeout: nil)
|
|
14
|
+
variables = Bodies.entries(items, "items")
|
|
15
|
+
VariableNames.assert_inputs(variables)
|
|
16
|
+
request("#{Paths.variables_path(project, environment)}/#{SEGMENTS[:BULK]}", method: HTTP_METHODS[:POST],
|
|
17
|
+
query: scoped(product), body: {"variables" => variables}, timeout:)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def update(project, environment, name, patch = nil, product: nil, timeout: nil, **fields)
|
|
21
|
+
payload = body_of(patch, fields)
|
|
22
|
+
VariableNames.assert_patch(payload)
|
|
23
|
+
request(Paths.variable_path(project, environment, name), method: HTTP_METHODS[:PATCH], query: scoped(product),
|
|
24
|
+
body: payload, timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update_by_id(id, patch = nil, product: nil, timeout: nil, **fields)
|
|
28
|
+
payload = body_of(patch, fields)
|
|
29
|
+
VariableNames.assert_patch(payload)
|
|
30
|
+
request(Paths.variable_by_id_path(id), method: HTTP_METHODS[:PATCH], query: scoped(product), body: payload,
|
|
31
|
+
timeout:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def delete(project, environment, name, product: nil, timeout: nil)
|
|
35
|
+
request(Paths.variable_path(project, environment, name), method: HTTP_METHODS[:DELETE], query: scoped(product),
|
|
36
|
+
timeout:)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def delete_by_id(id, product: nil, timeout: nil)
|
|
40
|
+
request(Paths.variable_by_id_path(id), method: HTTP_METHODS[:DELETE], query: scoped(product), timeout:)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def delete_many(project, environment, names, product: nil, timeout: nil)
|
|
44
|
+
request(Paths.variables_path(project, environment), method: HTTP_METHODS[:DELETE], query: scoped(product),
|
|
45
|
+
body: {"names" => list_of(names, "names")}, timeout:)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def apply(project, environment, changes = nil, product: nil, timeout: nil, **fields)
|
|
49
|
+
payload = body_of(changes, fields)
|
|
50
|
+
payload["creates"] = Bodies.entries(payload["creates"], "creates") if Wire.truthy?(payload["creates"])
|
|
51
|
+
VariableNames.assert_changes(payload)
|
|
52
|
+
request("#{Paths.variables_path(project, environment)}/#{SEGMENTS[:APPLY]}", method: HTTP_METHODS[:POST],
|
|
53
|
+
query: scoped(product), body: payload, timeout:)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Variables < Resource
|
|
6
|
+
def list(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(Paths.variables_path(project, environment), COLLECTIONS[:VARIABLES],
|
|
8
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_all(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
12
|
+
all(Paths.variables_path(project, environment), COLLECTIONS[:VARIABLES],
|
|
13
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def iterate(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil,
|
|
17
|
+
&block)
|
|
18
|
+
each_item(Paths.variables_path(project, environment), COLLECTIONS[:VARIABLES],
|
|
19
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get(project, environment, name, product: nil, timeout: nil)
|
|
23
|
+
request(Paths.variable_path(project, environment, name), query: scoped(product), timeout:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_by_id(id, product: nil, timeout: nil)
|
|
27
|
+
request(Paths.variable_by_id_path(id), query: scoped(product), timeout:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def list_history(project, environment, name, limit: nil, offset: nil, search: nil, order: nil, product: nil,
|
|
31
|
+
timeout: nil)
|
|
32
|
+
page(Paths.history_path(project, environment, name), COLLECTIONS[:EVENTS],
|
|
33
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_all_history(project, environment, name, limit: nil, offset: nil, search: nil, order: nil, product: nil,
|
|
37
|
+
timeout: nil)
|
|
38
|
+
all(Paths.history_path(project, environment, name), COLLECTIONS[:EVENTS],
|
|
39
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def iterate_history(project, environment, name, limit: nil, offset: nil, search: nil, order: nil, product: nil,
|
|
43
|
+
timeout: nil, &block)
|
|
44
|
+
each_item(Paths.history_path(project, environment, name), COLLECTIONS[:EVENTS],
|
|
45
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Versions < Resource
|
|
6
|
+
def list(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
7
|
+
page(Paths.versions_path(project, environment), COLLECTIONS[:VERSIONS],
|
|
8
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_all(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil)
|
|
12
|
+
all(Paths.versions_path(project, environment), COLLECTIONS[:VERSIONS],
|
|
13
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def iterate(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil, timeout: nil,
|
|
17
|
+
&block)
|
|
18
|
+
each_item(Paths.versions_path(project, environment), COLLECTIONS[:VERSIONS],
|
|
19
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(project, environment, body = nil, product: nil, timeout: nil, **fields)
|
|
23
|
+
request(Paths.versions_path(project, environment), method: HTTP_METHODS[:POST], query: scoped(product),
|
|
24
|
+
body: body_of(body, fields), timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get(id, product: nil, timeout: nil)
|
|
28
|
+
request(Paths.version_by_id_path(id), query: scoped(product), timeout:)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def rollback(id, product: nil, timeout: nil)
|
|
32
|
+
request("#{Paths.version_by_id_path(id)}/#{SEGMENTS[:ROLLBACK]}", method: HTTP_METHODS[:POST],
|
|
33
|
+
query: scoped(product), timeout:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_entries(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil,
|
|
37
|
+
timeout: nil)
|
|
38
|
+
page(Paths.entries_path(project, environment), COLLECTIONS[:ENTRIES],
|
|
39
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def list_all_entries(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil,
|
|
43
|
+
timeout: nil)
|
|
44
|
+
all(Paths.entries_path(project, environment), COLLECTIONS[:ENTRIES],
|
|
45
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def iterate_entries(project, environment, limit: nil, offset: nil, search: nil, order: nil, product: nil,
|
|
49
|
+
timeout: nil, &block)
|
|
50
|
+
each_item(Paths.entries_path(project, environment), COLLECTIONS[:ENTRIES],
|
|
51
|
+
Listing.of(limit:, offset:, search:, order:, product:), timeout, &block)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def reencrypt_entries(project, environment, entries, product: nil, timeout: nil)
|
|
55
|
+
request("#{Paths.entries_path(project, environment)}/#{SEGMENTS[:REENCRYPT]}", method: HTTP_METHODS[:POST],
|
|
56
|
+
query: scoped(product), body: {"entries" => list_of(entries, "entries")}, timeout:)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Envless
|
|
4
|
+
module Resources
|
|
5
|
+
class Webhooks < Resource
|
|
6
|
+
def list_deliveries(id, limit: nil, offset: nil, search: nil, order: nil, product: nil, status: nil, timeout: nil)
|
|
7
|
+
page(Paths.deliveries_path(id), COLLECTIONS[:DELIVERIES],
|
|
8
|
+
Listing.of(limit:, offset:, search:, order:, product:, status:), timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_all_deliveries(id, limit: nil, offset: nil, search: nil, order: nil, product: nil, status: nil,
|
|
12
|
+
timeout: nil)
|
|
13
|
+
all(Paths.deliveries_path(id), COLLECTIONS[:DELIVERIES],
|
|
14
|
+
Listing.of(limit:, offset:, search:, order:, product:, status:), timeout)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def iterate_deliveries(id, limit: nil, offset: nil, search: nil, order: nil, product: nil, status: nil,
|
|
18
|
+
timeout: nil, &block)
|
|
19
|
+
each_item(Paths.deliveries_path(id), COLLECTIONS[:DELIVERIES],
|
|
20
|
+
Listing.of(limit:, offset:, search:, order:, product:, status:), timeout, &block)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_delivery(id, delivery_id, timeout: nil)
|
|
24
|
+
request(Paths.delivery_path(id, delivery_id), timeout:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def redeliver(id, delivery_id, timeout: nil)
|
|
28
|
+
request("#{Paths.delivery_path(id, delivery_id)}/#{SEGMENTS[:REDELIVER]}", method: HTTP_METHODS[:POST],
|
|
29
|
+
timeout:)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|