Class: Marathon::ContainerDockerPortMapping
- Defined in:
- lib/marathon/container_docker_port_mapping.rb
Overview
This class represents a Marathon Container docker information. See mesosphere.github.io/marathon/docs/native-docker.html for full details.
Constant Summary collapse
- ACCESSORS =
%w[ containerPort hostPort servicePort protocol ]
- DEFAULTS =
{ :protocol => 'tcp', :hostPort => 0 }
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(hash) ⇒ ContainerDockerPortMapping
constructor
Create a new container docker port mappint object.
- #to_pretty_s ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
Methods included from Error
error_class, error_message, from_response
Constructor Details
#initialize(hash) ⇒ ContainerDockerPortMapping
Create a new container docker port mappint object. hash
: Hash returned by API.
13 14 15 16 17 18 19 20 21 |
# File 'lib/marathon/container_docker_port_mapping.rb', line 13 def initialize(hash) super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS) Marathon::Util.validate_choice('protocol', protocol, %w[tcp udp]) raise Marathon::Error::ArgumentError, 'containerPort must not be nil' unless containerPort raise Marathon::Error::ArgumentError, 'containerPort must be a non negative number' \ unless containerPort.is_a?(Integer) and containerPort >= 0 raise Marathon::Error::ArgumentError, 'hostPort must be a non negative number' \ unless hostPort.is_a?(Integer) and hostPort >= 0 end |
Instance Method Details
#to_pretty_s ⇒ Object
23 24 25 |
# File 'lib/marathon/container_docker_port_mapping.rb', line 23 def to_pretty_s "#{protocol}/#{containerPort}:#{hostPort}" end |
#to_s ⇒ Object
27 28 29 30 |
# File 'lib/marathon/container_docker_port_mapping.rb', line 27 def to_s "Marathon::ContainerDockerPortMapping { :protocol => #{protocol} " \ + ":containerPort => #{containerPort} :hostPort => #{hostPort} }" end |