Module: Endpoints
- Includes:
- Generic
- Included in:
- RubyKubernetesController::Client, Utilities
- Defined in:
- lib/ruby-kubernetes-controller/endpoints.rb
Instance Method Summary collapse
-
#create_new_endpoint(namespace, config) ⇒ Object
Create new Endpoint.
-
#delete_endpoint(namespace, endpoint_name, options = '') ⇒ Object
Delete existing Endpoint.
-
#get_all_endpoints ⇒ Object
Get all Endpoints.
-
#get_all_namespaced_endpoints(namespace) ⇒ Object
Get all existing Endpoints in Namespace.
-
#get_single_namespaced_endpoint(namespace, endpoint_name) ⇒ Object
Get single Endpoint in Namespace.
-
#patch_endpoint(namespace, endpoint_name, patch) ⇒ Object
Patch existing Endpoint.
-
#update_namespaced_endpoint(namespace, endpoint_name, update) ⇒ Object
Update existing Endpoint in Namespace.
Methods included from Generic
#check_valid_json, #prepareGenericRequest, #prepareGenericRequestOptions, #prepareURI, #prepareURIWithParams, #yaml_file_to_json
Instance Method Details
#create_new_endpoint(namespace, config) ⇒ Object
Create new Endpoint
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 13 def create_new_endpoint(namespace, config) extension = "/api/v1/namespaces/#{namespace}/endpoints" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "POST") request.content_type = "application/json" if @yaml request.body = yaml_file_to_json(config) else request.body = config end = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#delete_endpoint(namespace, endpoint_name, options = '') ⇒ Object
Delete existing Endpoint
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 154 def delete_endpoint(namespace, endpoint_name, = '') extension = "/api/v1/namespaces/#{namespace}/endpoints/#{endpoint_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "DELETE") request.content_type = "application/json" if @yaml request.body = yaml_file_to_json() else request.body = end = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_all_endpoints ⇒ Object
Get all Endpoints
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 41 def get_all_endpoints extension = "/api/v1/endpoints" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_all_namespaced_endpoints(namespace) ⇒ Object
Get all existing Endpoints in Namespace
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 62 def get_all_namespaced_endpoints(namespace) extension = "/api/v1/namespaces/#{namespace}/endpoints" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_single_namespaced_endpoint(namespace, endpoint_name) ⇒ Object
Get single Endpoint in Namespace
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 83 def get_single_namespaced_endpoint(namespace, endpoint_name) extension = "/api/v1/namespaces/#{namespace}/endpoints/#{endpoint_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#patch_endpoint(namespace, endpoint_name, patch) ⇒ Object
Patch existing Endpoint
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 131 def patch_endpoint(namespace, endpoint_name, patch) extension = "/api/v1/namespaces/#{namespace}/endpoints/#{endpoint_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "PATCH") request.content_type = "application/json-patch+json" request.body = patch = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#update_namespaced_endpoint(namespace, endpoint_name, update) ⇒ Object
Update existing Endpoint in Namespace
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ruby-kubernetes-controller/endpoints.rb', line 103 def update_namespaced_endpoint(namespace, endpoint_name, update) extension = "/api/v1/namespaces/#{namespace}/endpoints/#{endpoint_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "PUT") request.content_type = "application/json" if @yaml request.body = yaml_file_to_json(update) else request.body = update end = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |