render_ruby 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +23 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +21 -0
- data/README.md +208 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/render_ruby/client.rb +47 -0
- data/lib/render_ruby/collection.rb +27 -0
- data/lib/render_ruby/error.rb +6 -0
- data/lib/render_ruby/object.rb +22 -0
- data/lib/render_ruby/objects/custom_domain.rb +6 -0
- data/lib/render_ruby/objects/deploy.rb +6 -0
- data/lib/render_ruby/objects/environment_variable.rb +6 -0
- data/lib/render_ruby/objects/header.rb +6 -0
- data/lib/render_ruby/objects/job.rb +6 -0
- data/lib/render_ruby/objects/owner.rb +13 -0
- data/lib/render_ruby/objects/rule.rb +13 -0
- data/lib/render_ruby/objects/scale.rb +6 -0
- data/lib/render_ruby/objects/service.rb +15 -0
- data/lib/render_ruby/resource.rb +39 -0
- data/lib/render_ruby/resources/custom_domains.rb +25 -0
- data/lib/render_ruby/resources/deploys.rb +19 -0
- data/lib/render_ruby/resources/jobs.rb +21 -0
- data/lib/render_ruby/resources/owners.rb +15 -0
- data/lib/render_ruby/resources/services.rb +63 -0
- data/lib/render_ruby/version.rb +5 -0
- data/lib/render_ruby.rb +30 -0
- data/render_ruby.gemspec +37 -0
- data/sig/render_ruby.rbs +4 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0c069debe5692daabdea222c1fa705ac72af44bf08d134546ac9a367b0e359d7
|
4
|
+
data.tar.gz: 07b86db85f30550a75e9ebc095231ad083c027559d73aa75a1bd0803012a37e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ddf8492681ec9dbbd1cf4b2ceceb5199954e936bc93a714f8668423c01555b0778ef2781ff7470d9a0049457009ee102628d6086e029de139b98c9779a32a4c
|
7
|
+
data.tar.gz: 43e68ecb427cedd1b1cea1a272c6c210ed3252398fa7ff0758e6fcd9b76d3538c405faf20a5521404543ce11a049fc9acd278dba37fc04293f9cc849fe41994f
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
NewCops: disable
|
4
|
+
SuggestExtensions: false
|
5
|
+
|
6
|
+
Style/StringLiterals:
|
7
|
+
Enabled: true
|
8
|
+
EnforcedStyle: single_quotes
|
9
|
+
|
10
|
+
Style/StringLiteralsInInterpolation:
|
11
|
+
Enabled: true
|
12
|
+
EnforcedStyle: single_quotes
|
13
|
+
|
14
|
+
Layout/LineLength:
|
15
|
+
Max: 120
|
16
|
+
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Enabled: true
|
22
|
+
CountComments: false
|
23
|
+
Max: 20
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at nejdetkadir.550@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in render_ruby.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
|
10
|
+
gem 'minitest', '~> 5.0'
|
11
|
+
|
12
|
+
gem 'rubocop', '~> 1.21'
|
13
|
+
|
14
|
+
# HTTP/REST API client library [https://github.com/lostisland/faraday]
|
15
|
+
gem 'faraday', '~> 2.2'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
render_ruby (1.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
faraday (2.2.0)
|
11
|
+
faraday-net_http (~> 2.0)
|
12
|
+
ruby2_keywords (>= 0.0.4)
|
13
|
+
faraday-net_http (2.0.1)
|
14
|
+
minitest (5.15.0)
|
15
|
+
parallel (1.21.0)
|
16
|
+
parser (3.1.1.0)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
rainbow (3.1.1)
|
19
|
+
rake (13.0.6)
|
20
|
+
regexp_parser (2.2.1)
|
21
|
+
rexml (3.2.5)
|
22
|
+
rubocop (1.25.1)
|
23
|
+
parallel (~> 1.10)
|
24
|
+
parser (>= 3.1.0.0)
|
25
|
+
rainbow (>= 2.2.2, < 4.0)
|
26
|
+
regexp_parser (>= 1.8, < 3.0)
|
27
|
+
rexml
|
28
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
29
|
+
ruby-progressbar (~> 1.7)
|
30
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
31
|
+
rubocop-ast (1.16.0)
|
32
|
+
parser (>= 3.1.1.0)
|
33
|
+
ruby-progressbar (1.11.0)
|
34
|
+
ruby2_keywords (0.0.5)
|
35
|
+
unicode-display_width (2.1.0)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
arm64-darwin-21
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
faraday (~> 2.2)
|
42
|
+
minitest (~> 5.0)
|
43
|
+
rake (~> 13.0)
|
44
|
+
render_ruby!
|
45
|
+
rubocop (~> 1.21)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.3.3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 nejdetkadir
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
![test](https://github.com/nejdetkadir/render-ruby/actions/workflows/test.yml/badge.svg?branch=main)
|
2
|
+
![rubocop](https://github.com/nejdetkadir/render-ruby/actions/workflows/rubocop.yml/badge.svg?branch=main)
|
3
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
|
4
|
+
![Ruby Version](https://img.shields.io/badge/ruby_version->=_2.6.0-blue.svg)
|
5
|
+
|
6
|
+
# RenderRuby
|
7
|
+
Ruby bindings for [Render API](https://api-docs.render.com)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'render_ruby'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install render_ruby
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
To access the API, you'll need to create a RenderRuby::Client and pass in your API key. You can find your API key at https://render.com/docs/api
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
client = RenderRuby::Client.new(api_key: ENV['RENDER_API_KEY'])
|
30
|
+
```
|
31
|
+
The client then gives you access to each of the resources.
|
32
|
+
|
33
|
+
## Resources
|
34
|
+
The gem maps as closely as we can to the Render API so you can easily convert API examples to gem code.
|
35
|
+
|
36
|
+
Responses are created as objects like RenderRuby::Owner. Having types like RenderRuby::Owner is handy for understanding what type of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way.
|
37
|
+
|
38
|
+
#### Pagination
|
39
|
+
|
40
|
+
`list` endpoints return pages of results. The result object will have a data key to access the results, as well as metadata like next_cursor and prev_cursor for retrieving the next and previous pages. You may also specify the
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
results = client.owners.list(limit: 100) # limit is optional, defaults to 20.
|
44
|
+
#=> RenderRuby::Collection
|
45
|
+
|
46
|
+
results.total
|
47
|
+
#=> 55
|
48
|
+
|
49
|
+
results.data
|
50
|
+
#=> [#<RenderRuby::Owner>, #<RenderRuby::Owner>]
|
51
|
+
|
52
|
+
results.next_cursor
|
53
|
+
#=> "XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ"
|
54
|
+
|
55
|
+
# Retrieve the next page
|
56
|
+
client.owners.list(limit: 100, cursor: results.next_cursor)
|
57
|
+
#=> RenderRuby::Collection
|
58
|
+
```
|
59
|
+
|
60
|
+
### Owners
|
61
|
+
```ruby
|
62
|
+
response = client.owners.list
|
63
|
+
#=> RenderRuby::Collection
|
64
|
+
|
65
|
+
response.data.first.user?
|
66
|
+
#=> true
|
67
|
+
|
68
|
+
response.data.first.team?
|
69
|
+
#=> false
|
70
|
+
|
71
|
+
client.owners.retrieve(owner_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
72
|
+
#=> RenderRuby::Owner
|
73
|
+
```
|
74
|
+
|
75
|
+
### Services
|
76
|
+
```ruby
|
77
|
+
client.services.list
|
78
|
+
#=> RenderRuby::Collection
|
79
|
+
|
80
|
+
service = client.services.retrieve(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
81
|
+
#=> RenderRuby::Service
|
82
|
+
|
83
|
+
service.auto_deploy_enabled?
|
84
|
+
#=> true
|
85
|
+
|
86
|
+
service.suspended?
|
87
|
+
#=> false
|
88
|
+
|
89
|
+
RenderRuby::Service::TYPES
|
90
|
+
#=> ['static_site', 'web_service', 'private_service', 'background_worker', 'cron_job']
|
91
|
+
|
92
|
+
client.services.create(
|
93
|
+
type: RenderRuby::Service::TYPES.sample,
|
94
|
+
name: 'foo bar',
|
95
|
+
ownerId: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
|
96
|
+
repo: 'https://github.com/render-examples/flask-hello-world',
|
97
|
+
autoDeploy: 'yes', # or 'no',
|
98
|
+
branch: 'master'
|
99
|
+
)
|
100
|
+
#=> RenderRuby::Service
|
101
|
+
|
102
|
+
client.services.update(
|
103
|
+
service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
|
104
|
+
name: 'foo bar',
|
105
|
+
autoDeploy: 'yes', # or 'no',
|
106
|
+
branch: 'master'
|
107
|
+
)
|
108
|
+
#=> RenderRuby::Service
|
109
|
+
|
110
|
+
client.services.delete(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
111
|
+
#=> Faraday::Response
|
112
|
+
|
113
|
+
client.services.suspend(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
114
|
+
#=> Faraday::Response
|
115
|
+
|
116
|
+
client.services.resume(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
117
|
+
#=> Faraday::Response
|
118
|
+
|
119
|
+
client.services.retrieve_env_vars(service_id:'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
120
|
+
#=> RenderRuby::Collection
|
121
|
+
|
122
|
+
client.services.update_env_var(
|
123
|
+
service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
|
124
|
+
env_vars: [
|
125
|
+
{
|
126
|
+
name: 'FOO',
|
127
|
+
value: 'bar'
|
128
|
+
}
|
129
|
+
]
|
130
|
+
)
|
131
|
+
#=> RenderRuby::EnvironmentVariable
|
132
|
+
|
133
|
+
client.services.retrieve_headers(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
134
|
+
#=> RenderRuby::Collection
|
135
|
+
|
136
|
+
results = client.services.retrieve_redirect_and_rewrite_rules(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
137
|
+
#=> RenderRuby::Collection
|
138
|
+
|
139
|
+
results.data.first.redirect?
|
140
|
+
#=> true
|
141
|
+
|
142
|
+
results.data.first.rewrite?
|
143
|
+
#=> false
|
144
|
+
|
145
|
+
client.services.scale(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ', num_instances: 1)
|
146
|
+
#=> RenderRuby::Scale
|
147
|
+
```
|
148
|
+
|
149
|
+
### Jobs
|
150
|
+
```ruby
|
151
|
+
client.jobs.list(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
152
|
+
#=> RenderRuby::Collection
|
153
|
+
|
154
|
+
client.jobs.retrieve(service_id: 'XMTjXEjiQJm', job_id: 'XMTjXEjiQJ')
|
155
|
+
#=> RenderRuby::Job
|
156
|
+
|
157
|
+
client.jobs.create(
|
158
|
+
service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
|
159
|
+
start_command: 'yarn dev',
|
160
|
+
planId: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ' # optional
|
161
|
+
)
|
162
|
+
#=> RenderRuby::Job
|
163
|
+
```
|
164
|
+
|
165
|
+
### Deploys
|
166
|
+
```ruby
|
167
|
+
client.deploys.list(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
168
|
+
#=> RenderRuby::Collection
|
169
|
+
|
170
|
+
client.deploys.retrieve(service_id: 'XMTjXEjiQJm', deploy_id: 'XMTjXEjiQJ')
|
171
|
+
#=> RenderRuby::Deploy
|
172
|
+
|
173
|
+
client.deploys.trigger(
|
174
|
+
service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
|
175
|
+
clear_cache: 'clear' # or 'do_not_clear'
|
176
|
+
)
|
177
|
+
#=> RenderRuby::Deploy
|
178
|
+
```
|
179
|
+
|
180
|
+
### Custom Domains
|
181
|
+
```ruby
|
182
|
+
client.custom_domains.list(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
|
183
|
+
#=> RenderRuby::Collection
|
184
|
+
|
185
|
+
client.custom_domains.retrieve(service_id: 'XMTjXEjiQJm', custom_domain_id: 'XMTjXEjiQJ')
|
186
|
+
#=> RenderRuby::CustomDomain
|
187
|
+
|
188
|
+
client.custom_domains.create(
|
189
|
+
service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
|
190
|
+
domain: 'www.nejdetkadirbektas.com'
|
191
|
+
)
|
192
|
+
#=> RenderRuby::CustomDomain
|
193
|
+
|
194
|
+
client.custom_domains.delete(service_id: 'XMTjXEjiQJm', custom_domain_id: 'XMTjXEjiQJ')
|
195
|
+
#=> Faraday::Response
|
196
|
+
```
|
197
|
+
|
198
|
+
## Contributing
|
199
|
+
|
200
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nejdetkadir/render-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/nejdetkadir/render-ruby/blob/main/CODE_OF_CONDUCT.md).
|
201
|
+
|
202
|
+
## License
|
203
|
+
|
204
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE).
|
205
|
+
|
206
|
+
## Code of Conduct
|
207
|
+
|
208
|
+
Everyone interacting in the RenderRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nejdetkadir/render-ruby/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/test_*.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'render_ruby'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class Client
|
5
|
+
BASE_URL = 'https://api.render.com/v1'
|
6
|
+
|
7
|
+
attr_reader :api_key, :adapter
|
8
|
+
|
9
|
+
def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil)
|
10
|
+
@api_key = api_key
|
11
|
+
@adapter = adapter
|
12
|
+
|
13
|
+
# Test stubs for requests
|
14
|
+
@stubs = stubs
|
15
|
+
end
|
16
|
+
|
17
|
+
def owners
|
18
|
+
OwnerResource.new(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def services
|
22
|
+
ServiceResource.new(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
def deploys
|
26
|
+
DeployResource.new(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def custom_domains
|
30
|
+
CustomDomainResource.new(self)
|
31
|
+
end
|
32
|
+
|
33
|
+
def jobs
|
34
|
+
JobResource.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
def connection
|
38
|
+
@connection ||= Faraday.new(BASE_URL) do |conn|
|
39
|
+
conn.request :authorization, :Bearer, api_key
|
40
|
+
conn.request :json
|
41
|
+
conn.response :json, content_type: 'application/json'
|
42
|
+
|
43
|
+
conn.adapter adapter, @stubs
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class Collection
|
5
|
+
attr_reader :data, :total, :next_cursor, :prev_cursor
|
6
|
+
|
7
|
+
def self.from_response(response, type:)
|
8
|
+
body = response.body
|
9
|
+
|
10
|
+
return new(data: [], total: 0, next_cursor: '', prev_cursor: '') if body.empty?
|
11
|
+
|
12
|
+
new(
|
13
|
+
data: body.map { |attrs| type.new(attrs) },
|
14
|
+
total: body.count,
|
15
|
+
next_cursor: body.last['cursor'],
|
16
|
+
prev_cursor: body.first['cursor']
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(data:, total:, next_cursor:, prev_cursor:)
|
21
|
+
@data = data
|
22
|
+
@total = total
|
23
|
+
@next_cursor = next_cursor
|
24
|
+
@prev_cursor = prev_cursor
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module RenderRuby
|
6
|
+
class Object < OpenStruct
|
7
|
+
def initialize(attributes)
|
8
|
+
super to_ostruct(attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_ostruct(obj)
|
12
|
+
case obj
|
13
|
+
when Hash
|
14
|
+
OpenStruct.new(obj.transform_values { |val| to_ostruct(val) })
|
15
|
+
when Array
|
16
|
+
obj.map { |o| to_ostruct(o) }
|
17
|
+
else # Assumed to be a primitive value
|
18
|
+
obj
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class Service < Object
|
5
|
+
TYPES = %w[static_site web_service private_service background_worker cron_job].freeze
|
6
|
+
|
7
|
+
def auto_deploy_enabled?
|
8
|
+
autoDeploy.equal?('yes')
|
9
|
+
end
|
10
|
+
|
11
|
+
def suspended?
|
12
|
+
suspended.equal?('suspended')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class Resource
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def get_request(url, params: {}, headers: {})
|
14
|
+
handle_response client.connection.get(url, params, headers)
|
15
|
+
end
|
16
|
+
|
17
|
+
def post_request(url, body:, headers: {})
|
18
|
+
handle_response client.connection.post(url, body, headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
def patch_request(url, body:, headers: {})
|
22
|
+
handle_response client.connection.patch(url, body, headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
def put_request(url, body:, headers: {})
|
26
|
+
handle_response client.connection.put(url, body, headers)
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete_request(url, params: {}, headers: {})
|
30
|
+
handle_response client.connection.delete(url, params, headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
def handle_response(response)
|
34
|
+
raise Error, response.body['message'] unless [200, 201, 202, 204].include?(response.status)
|
35
|
+
|
36
|
+
response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class CustomDomainResource < Resource
|
5
|
+
def list(service_id:, **params)
|
6
|
+
response = get_request("services/#{service_id}/custom-domains", params: params)
|
7
|
+
|
8
|
+
Collection.from_response(response, type: CustomDomain)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(service_id:, custom_domain_id:)
|
12
|
+
CustomDomain.new get_request("services/#{service_id}/custom-domains/#{custom_domain_id}").body
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(service_id:, domain:)
|
16
|
+
response = post_request("services/#{service_id}/custom-domains", body: { name: domain })
|
17
|
+
|
18
|
+
Collection.from_response(response, type: CustomDomain)
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(service_id:, custom_domain_id:)
|
22
|
+
delete_request("services/#{service_id}/custom-domains/#{custom_domain_id}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class DeployResource < Resource
|
5
|
+
def list(service_id:, **params)
|
6
|
+
response = get_request("services/#{service_id}/deploys", params: params)
|
7
|
+
|
8
|
+
Collection.from_response(response, type: Deploy)
|
9
|
+
end
|
10
|
+
|
11
|
+
def trigger(service_id:, clear_cache:)
|
12
|
+
Deploy.new post_request("services/#{service_id}/deploys", body: { clearCache: clear_cache }).body
|
13
|
+
end
|
14
|
+
|
15
|
+
def retrieve(service_id:, deploy_id:)
|
16
|
+
Deploy.new get_request("services/#{service_id}/deploys/#{deploy_id}").body
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class JobResource < Resource
|
5
|
+
def list(service_id:, **params)
|
6
|
+
response = get_request("services/#{service_id}/jobs", params: params)
|
7
|
+
|
8
|
+
Collection.from_response(response, type: Job)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(service_id:, job_id:)
|
12
|
+
Job.new get_request("services/#{service_id}/jobs/#{job_id}").body
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(service_id:, start_command:, **attributes)
|
16
|
+
attributes = attributes.merge(startCommand: start_command)
|
17
|
+
|
18
|
+
Job.new post_request("services/#{service_id}/jobs", body: attributes).body
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class OwnerResource < Resource
|
5
|
+
def list(**params)
|
6
|
+
response = get_request('owners', params: params)
|
7
|
+
|
8
|
+
Collection.from_response(response, type: Owner)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(owner_id:)
|
12
|
+
Owner.new get_request("owners/#{owner_id}").body
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderRuby
|
4
|
+
class ServiceResource < Resource
|
5
|
+
def list(**params)
|
6
|
+
response = get_request('services', params: params)
|
7
|
+
|
8
|
+
Collection.from_response(response, type: Service)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(service_id:)
|
12
|
+
Service.new get_request("services/#{service_id}").body
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(**attributes)
|
16
|
+
Service.new post_request('services', body: attributes).body
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(service_id:, **attributes)
|
20
|
+
Service.new patch_request("services/#{service_id}", body: attributes).body
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(service_id:)
|
24
|
+
delete_request("services/#{service_id}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def suspend(service_id:)
|
28
|
+
post_request("services/#{service_id}/suspend", body: {})
|
29
|
+
end
|
30
|
+
|
31
|
+
def resume(service_id:)
|
32
|
+
post_request("services/#{service_id}/resume", body: {})
|
33
|
+
end
|
34
|
+
|
35
|
+
def retrieve_env_vars(service_id:, **params)
|
36
|
+
response = get_request("services/#{service_id}/env-vars", params: params)
|
37
|
+
|
38
|
+
Collection.from_response(response, type: EnvironmentVariable)
|
39
|
+
end
|
40
|
+
|
41
|
+
def update_env_var(service_id:, env_vars:)
|
42
|
+
response = put_request("services/#{service_id}/env-vars", body: env_vars)
|
43
|
+
|
44
|
+
Collection.from_response(response, type: EnvironmentVariable)
|
45
|
+
end
|
46
|
+
|
47
|
+
def retrieve_headers(service_id:, **params)
|
48
|
+
response = get_request("services/#{service_id}/headers", params: params)
|
49
|
+
|
50
|
+
Collection.from_response(response, type: Header)
|
51
|
+
end
|
52
|
+
|
53
|
+
def retrieve_redirect_and_rewrite_rules(service_id:, **params)
|
54
|
+
response = get_request("services/#{service_id}/routes", params: params)
|
55
|
+
|
56
|
+
Collection.from_response(response, type: Rule)
|
57
|
+
end
|
58
|
+
|
59
|
+
def scale(service_id:, num_instances:)
|
60
|
+
Scale.new post_request("services/#{service_id}/scale", body: { numInstances: num_instances }).body
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/render_ruby.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require_relative 'render_ruby/version'
|
5
|
+
|
6
|
+
module RenderRuby
|
7
|
+
autoload :Client, 'render_ruby/client'
|
8
|
+
autoload :Error, 'render_ruby/error'
|
9
|
+
autoload :Collection, 'render_ruby/collection'
|
10
|
+
autoload :Resource, 'render_ruby/resource'
|
11
|
+
autoload :Object, 'render_ruby/object'
|
12
|
+
|
13
|
+
# resources
|
14
|
+
autoload :OwnerResource, 'render_ruby/resources/owners'
|
15
|
+
autoload :ServiceResource, 'render_ruby/resources/services'
|
16
|
+
autoload :DeployResource, 'render_ruby/resources/deploys'
|
17
|
+
autoload :CustomDomainResource, 'render_ruby/resources/custom_domains'
|
18
|
+
autoload :JobResource, 'render_ruby/resources/jobs'
|
19
|
+
|
20
|
+
# objects
|
21
|
+
autoload :Owner, 'render_ruby/objects/owner'
|
22
|
+
autoload :Service, 'render_ruby/objects/service'
|
23
|
+
autoload :EnvironmentVariable, 'render_ruby/objects/environment_variable'
|
24
|
+
autoload :Header, 'render_ruby/objects/header'
|
25
|
+
autoload :Rule, 'render_ruby/objects/rule'
|
26
|
+
autoload :Scale, 'render_ruby/objects/scale'
|
27
|
+
autoload :Deploy, 'render_ruby/objects/deploy'
|
28
|
+
autoload :CustomDomain, 'render_ruby/objects/custom_domain'
|
29
|
+
autoload :Job, 'render_ruby/objects/job'
|
30
|
+
end
|
data/render_ruby.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/render_ruby/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'render_ruby'
|
7
|
+
spec.version = RenderRuby::VERSION
|
8
|
+
spec.authors = ['nejdetkadir']
|
9
|
+
spec.email = ['nejdetkadir.550@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Ruby bindings for Render API'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/nejdetkadir/render-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.6.0'
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = 'exe'
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, check out our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
end
|
data/sig/render_ruby.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: render_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nejdetkadir
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby bindings for Render API
|
14
|
+
email:
|
15
|
+
- nejdetkadir.550@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".rubocop.yml"
|
21
|
+
- CHANGELOG.md
|
22
|
+
- CODE_OF_CONDUCT.md
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/console
|
29
|
+
- bin/setup
|
30
|
+
- lib/render_ruby.rb
|
31
|
+
- lib/render_ruby/client.rb
|
32
|
+
- lib/render_ruby/collection.rb
|
33
|
+
- lib/render_ruby/error.rb
|
34
|
+
- lib/render_ruby/object.rb
|
35
|
+
- lib/render_ruby/objects/custom_domain.rb
|
36
|
+
- lib/render_ruby/objects/deploy.rb
|
37
|
+
- lib/render_ruby/objects/environment_variable.rb
|
38
|
+
- lib/render_ruby/objects/header.rb
|
39
|
+
- lib/render_ruby/objects/job.rb
|
40
|
+
- lib/render_ruby/objects/owner.rb
|
41
|
+
- lib/render_ruby/objects/rule.rb
|
42
|
+
- lib/render_ruby/objects/scale.rb
|
43
|
+
- lib/render_ruby/objects/service.rb
|
44
|
+
- lib/render_ruby/resource.rb
|
45
|
+
- lib/render_ruby/resources/custom_domains.rb
|
46
|
+
- lib/render_ruby/resources/deploys.rb
|
47
|
+
- lib/render_ruby/resources/jobs.rb
|
48
|
+
- lib/render_ruby/resources/owners.rb
|
49
|
+
- lib/render_ruby/resources/services.rb
|
50
|
+
- lib/render_ruby/version.rb
|
51
|
+
- render_ruby.gemspec
|
52
|
+
- sig/render_ruby.rbs
|
53
|
+
homepage: https://github.com/nejdetkadir/render-ruby
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata:
|
57
|
+
homepage_uri: https://github.com/nejdetkadir/render-ruby
|
58
|
+
source_code_uri: https://github.com/nejdetkadir/render-ruby
|
59
|
+
changelog_uri: https://github.com/nejdetkadir/render-ruby/blob/main/CHANGELOG.md
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.6.0
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubygems_version: 3.3.3
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Ruby bindings for Render API
|
79
|
+
test_files: []
|