fortress-sdk-ruby 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +2 -2
- data/examples/test.rb +1 -1
- data/lib/fortress/version.rb +1 -1
- data/lib/fortress.rb +11 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8689daa20a121a8be343a762dd72eddb09679ffe5596b44450a236f0cb956d87
|
4
|
+
data.tar.gz: 5f8b2924947bfc09c5e2ff80f43c28128da0eda9382e72ee724073b40e97e876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 204b6fec4d0f5c9c949cc910d3d3bf83ad3c78c3183a060e5528beea2714d9dc3bec98accfe4c5de0e60c6bb961f9fc3331dd0c76d1c39a0c406ed63e09935c3
|
7
|
+
data.tar.gz: d6bb8b42a50046b6c628d71b7795dab4739e40bd4f7b97b058307262ec733554f3e6b090a96c98863ccd802d8b937cad96dec99f5081707800fee4b164b140e9
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Welcome to the Fortress Ruby SDK. This SDK provides a way for you to leverage th
|
|
7
7
|
You can install the SDK using Gem. Simply run the following command:
|
8
8
|
|
9
9
|
```bash
|
10
|
-
gem install
|
10
|
+
gem install fortress-sdk-ruby
|
11
11
|
```
|
12
12
|
|
13
13
|
## Quick Start
|
@@ -15,7 +15,7 @@ gem install fortress_sdk_ruby
|
|
15
15
|
Here is a quick example to get you started with the SDK:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
require '
|
18
|
+
require 'fortress'
|
19
19
|
|
20
20
|
# Initialize the client
|
21
21
|
client = Fortress::Client.new(api_key, organization_id)
|
data/examples/test.rb
CHANGED
@@ -7,7 +7,7 @@ client = Fortress::Fortress.new('orgId', 'apiKey')
|
|
7
7
|
id = client.create_database('Client 1')
|
8
8
|
|
9
9
|
# Create a tenant in that database
|
10
|
-
client.create_tenant('client1', 'Client 1', id)
|
10
|
+
client.create_tenant('client1', 'dedicate', 'aws', 'Client 1', id)
|
11
11
|
|
12
12
|
# List all tenants
|
13
13
|
client.list_tenants.each do |tenant|
|
data/lib/fortress/version.rb
CHANGED
data/lib/fortress.rb
CHANGED
@@ -45,12 +45,15 @@ module Fortress
|
|
45
45
|
def initialize(org_id, api_key)
|
46
46
|
@org_id = org_id
|
47
47
|
@api_key = api_key
|
48
|
+
@tenant_connection_cache = {}
|
48
49
|
end
|
49
50
|
|
50
51
|
# Connect to a tenant.
|
51
52
|
# @param id [String] The tenant ID.
|
52
53
|
# @return [PG::Connection] The connection to the tenant database.
|
53
54
|
def connect_tenant(id)
|
55
|
+
return @tenant_connection_cache[id] if @tenant_connection_cache.key?(id)
|
56
|
+
|
54
57
|
connection_details = get_connection_uri(id, 'tenant')
|
55
58
|
PG::Connection.new(dbname: connection_details.database, user: connection_details.username,
|
56
59
|
password: connection_details.password, host: connection_details.url, port: connection_details.port)
|
@@ -59,11 +62,13 @@ module Fortress
|
|
59
62
|
# Create a tenant in a database.
|
60
63
|
# @param id [String] The tenant ID.
|
61
64
|
# @param tenant_alias [String] The tenant alias.
|
62
|
-
# @param
|
65
|
+
# @param isolation_level [String] The isolation level for the tenant (shared or dedicated).
|
66
|
+
# @param platform [String] The cloud platform (aws or managed).
|
67
|
+
# @param database_id [String] The database ID. (either cloud_provider or database_id must be provided)
|
63
68
|
# @return [void]
|
64
|
-
def create_tenant(id, tenant_alias, database_id = nil)
|
69
|
+
def create_tenant(id, tenant_alias, isolation_level, platform_provider, database_id = nil)
|
65
70
|
endpoint = "#{BASE_URL}/v1/organization/#{@org_id}/tenant/#{id}"
|
66
|
-
body = { alias: tenant_alias }
|
71
|
+
body = { alias: tenant_alias, isolation: isolation_level, platform: platform_provider }
|
67
72
|
body[:databaseId] = database_id if database_id
|
68
73
|
_ = make_request(:post, endpoint, body)
|
69
74
|
end
|
@@ -87,21 +92,13 @@ module Fortress
|
|
87
92
|
_ = make_request(:delete, endpoint)
|
88
93
|
end
|
89
94
|
|
90
|
-
# Connect to a database.
|
91
|
-
# @param id [String] The database ID.
|
92
|
-
# @return [PG::Connection] The connection to the database.
|
93
|
-
def connect_database(id)
|
94
|
-
connection_details = get_connection_uri(id, 'database')
|
95
|
-
PG::Connection.new(dbname: connection_details.database, user: connection_details.username,
|
96
|
-
password: connection_details.password, host: connection_details.url, port: connection_details.port)
|
97
|
-
end
|
98
|
-
|
99
95
|
# Create a database.
|
100
96
|
# @param database_alias [String] The database alias.
|
97
|
+
# @param platform [String] The cloud provider (aws or managed).
|
101
98
|
# @return [String] The database ID.
|
102
|
-
def create_database(database_alias)
|
99
|
+
def create_database(database_alias, platform_provider)
|
103
100
|
endpoint = "#{BASE_URL}/v1/organization/#{@org_id}/database"
|
104
|
-
response = make_request(:post, endpoint, { alias: database_alias })
|
101
|
+
response = make_request(:post, endpoint, { alias: database_alias, platform: platform_provider })
|
105
102
|
response['id']
|
106
103
|
end
|
107
104
|
|
@@ -150,8 +147,6 @@ module Fortress
|
|
150
147
|
request['Content-Type'] = 'application/json'
|
151
148
|
request['Api-Key'] = @api_key
|
152
149
|
http = Net::HTTP.new(uri.host, uri.port)
|
153
|
-
|
154
|
-
# TODO: Enable SSL
|
155
150
|
http.use_ssl = true
|
156
151
|
|
157
152
|
request.body = body.to_json if body
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortress-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fortress
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is the official Ruby SDK for Fortress. It provides a simple way
|
14
14
|
to interact with the Fortress API.
|