Giter Site home page Giter Site logo

nejdetkadir / render-ruby Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 31 KB

Ruby bindings for Render API V1

Home Page: https://api-docs.render.com/reference/introduction

License: MIT License

Ruby 98.94% Shell 1.06%
ruby ruby-gem client render render-com ruby-bindings ruby-client

render-ruby's Introduction

Gem Version test rubocop Ruby Style Guide Ruby Version

RenderRuby

Ruby bindings for Render API

Installation

Add this line to your application's Gemfile:

gem 'render_ruby'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install render_ruby

Usage

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

client = RenderRuby::Client.new(api_key: ENV['RENDER_API_KEY'])

The client then gives you access to each of the resources.

Resources

The gem maps as closely as we can to the Render API so you can easily convert API examples to gem code.

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.

Pagination

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

results = client.owners.list(limit: 100) # limit is optional, defaults to 20.
#=> RenderRuby::Collection

results.total
#=> 55

results.data
#=> [#<RenderRuby::Owner>, #<RenderRuby::Owner>]

results.next_cursor
#=> "XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ"

# Retrieve the next page
client.owners.list(limit: 100, cursor: results.next_cursor)
#=> RenderRuby::Collection

Owners

response = client.owners.list
#=> RenderRuby::Collection

response.data.first.user?
#=> true

response.data.first.team?
#=> false

client.owners.retrieve(owner_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Owner

Services

client.services.list
#=> RenderRuby::Collection

service = client.services.retrieve(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Service

service.auto_deploy_enabled?
#=> true

service.suspended?
#=> false

RenderRuby::Service::TYPES
#=> ['static_site', 'web_service', 'private_service', 'background_worker', 'cron_job']

client.services.create(
  type: RenderRuby::Service::TYPES.sample,
  name: 'foo bar',
  ownerId: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
  repo: 'https://github.com/render-examples/flask-hello-world',
  autoDeploy: 'yes', # or 'no',
  branch: 'master'
)
#=> RenderRuby::Service

client.services.update(
  service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
  name: 'foo bar',
  autoDeploy: 'yes', # or 'no',
  branch: 'master'
)
#=> RenderRuby::Service

client.services.delete(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> Faraday::Response

client.services.suspend(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> Faraday::Response

client.services.resume(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> Faraday::Response

client.services.retrieve_env_vars(service_id:'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Collection

client.services.update_env_var(
  service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
  env_vars: [
    {
       name: 'FOO',
       value: 'bar'
    }
  ]
)
#=> RenderRuby::EnvironmentVariable

client.services.retrieve_headers(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Collection

results = client.services.retrieve_redirect_and_rewrite_rules(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Collection

results.data.first.redirect?
#=> true

results.data.first.rewrite?
#=> false

client.services.scale(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ', num_instances: 1)
#=> RenderRuby::Scale

Jobs

client.jobs.list(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Collection

client.jobs.retrieve(service_id: 'XMTjXEjiQJm', job_id: 'XMTjXEjiQJ')
#=> RenderRuby::Job

client.jobs.create(
  service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
  start_command: 'yarn dev',
  planId: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ' # optional
)
#=> RenderRuby::Job

Deploys

client.deploys.list(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Collection

client.deploys.retrieve(service_id: 'XMTjXEjiQJm', deploy_id: 'XMTjXEjiQJ')
#=> RenderRuby::Deploy

client.deploys.trigger(
  service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
  clear_cache: 'clear' # or 'do_not_clear'
)
#=> RenderRuby::Deploy

Custom Domains

client.custom_domains.list(service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ')
#=> RenderRuby::Collection

client.custom_domains.retrieve(service_id: 'XMTjXEjiQJm', custom_domain_id: 'XMTjXEjiQJ')
#=> RenderRuby::CustomDomain

client.custom_domains.create(
  service_id: 'XMTjXEjiQJmNjEwZ2QwZWQ5N2x2MGZ',
  domain: 'www.nejdetkadirbektas.com'
)
#=> RenderRuby::CustomDomain

client.custom_domains.delete(service_id: 'XMTjXEjiQJm', custom_domain_id: 'XMTjXEjiQJ')
#=> Faraday::Response

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the RenderRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

render-ruby's People

Contributors

nejdetkadir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.