Module: Namespaces
- Includes:
- Generic
- Included in:
- RubyKubernetesController::Client, Utilities
- Defined in:
- lib/ruby-kubernetes-controller/namespaces.rb
Instance Method Summary collapse
-
#create_new_namespace(config) ⇒ Object
Create new Namespace.
-
#delete_namespace(namespace, options = '') ⇒ Object
Delete existing Namespace.
-
#get_all_namespaces ⇒ Object
Get Namespaces.
-
#patch_namespace(namespace, patch) ⇒ Object
Patch existing Namespace.
-
#update_namespace(namespace, update) ⇒ Object
Update existing Namespace.
Methods included from Generic
#check_valid_json, #prepareGenericRequest, #prepareGenericRequestOptions, #prepareURI, #prepareURIWithParams, #yaml_file_to_json
Instance Method Details
#create_new_namespace(config) ⇒ Object
Create new Namespace
12 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 39 |
# File 'lib/ruby-kubernetes-controller/namespaces.rb', line 12 def create_new_namespace(config) extension = "/api/v1/namespaces" 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_namespace(namespace, options = '') ⇒ Object
Delete existing Namespace
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/ruby-kubernetes-controller/namespaces.rb', line 115 def delete_namespace(namespace, = '') extension = "/api/v1/namespaces/#{namespace}" 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_namespaces ⇒ Object
Get Namespaces
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ruby-kubernetes-controller/namespaces.rb', line 42 def get_all_namespaces extension = '/api/v1/namespaces' 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_namespace(namespace, patch) ⇒ Object
Patch existing Namespace
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ruby-kubernetes-controller/namespaces.rb', line 91 def patch_namespace(namespace, patch) extension = "/api/v1/namespaces/#{namespace}" 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_namespace(namespace, update) ⇒ Object
Update existing Namespace
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ruby-kubernetes-controller/namespaces.rb', line 63 def update_namespace(namespace, update) extension = "/api/v1/namespaces/#{namespace}" 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 |