Class: Google::Cloud::Gemserver::CLI::Request
- Inherits:
-
Object
- Object
- Google::Cloud::Gemserver::CLI::Request
- Defined in:
- lib/google/cloud/gemserver/cli/request.rb
Overview
Request
Responsible for sending requests to the gemserver for operations that involve the database. Gem operations are done with the 'gem' command and are not in the scope of Request.
Instance Attribute Summary collapse
-
#http ⇒ Net::HTTP
The HTTP object used to connect to and send requests to the gemserver.
Instance Method Summary collapse
-
#create_key(permissions = nil) ⇒ Net::HTTPResponse
Send a request to the gemserver to create a key with certain permissions.
-
#delete_key(key) ⇒ Net::HTTPResponse
Send a request to the gemserver to delete a key.
-
#health ⇒ Net::HTTPResponse
Sends a request to the gemserver to ensure it is accessible.
-
#initialize(url = nil, proj_name = nil) ⇒ Request
constructor
Initialize the Backend object by constructing an HTTP object for the gemserver.
-
#stats ⇒ Net::HTTPResponse
Send a request to the gemserver to fetch information about stored private gems and cached gem dependencies.
Constructor Details
#initialize(url = nil, proj_name = nil) ⇒ Request
Initialize the Backend object by constructing an HTTP object for the gemserver.
gemserver was deployed to. Optional.
46 47 48 49 |
# File 'lib/google/cloud/gemserver/cli/request.rb', line 46 def initialize url = nil, proj_name = nil gemserver_url = url.nil? == true ? remote(proj_name) : url @http = Net::HTTP.new gemserver_url end |
Instance Attribute Details
#http ⇒ Net::HTTP
The HTTP object used to connect to and send requests to the gemserver.
36 37 38 |
# File 'lib/google/cloud/gemserver/cli/request.rb', line 36 def http @http end |
Instance Method Details
#create_key(permissions = nil) ⇒ Net::HTTPResponse
Send a request to the gemserver to create a key with certain permissions.
have (read, write, or both). Optional.
59 60 61 |
# File 'lib/google/cloud/gemserver/cli/request.rb', line 59 def create_key = nil send_req Net::HTTP::Post, "/api/v1/key", {permissions: } end |
#delete_key(key) ⇒ Net::HTTPResponse
Send a request to the gemserver to delete a key.
69 70 71 |
# File 'lib/google/cloud/gemserver/cli/request.rb', line 69 def delete_key key send_req Net::HTTP::Put, "/api/v1/key", {key: key} end |
#health ⇒ Net::HTTPResponse
Sends a request to the gemserver to ensure it is accessible.
86 87 88 |
# File 'lib/google/cloud/gemserver/cli/request.rb', line 86 def health send_req Net::HTTP::Get, "/health" end |
#stats ⇒ Net::HTTPResponse
Send a request to the gemserver to fetch information about stored private gems and cached gem dependencies.
78 79 80 |
# File 'lib/google/cloud/gemserver/cli/request.rb', line 78 def stats send_req Net::HTTP::Post, "/api/v1/stats" end |