Class: Ruzbx::Api::Host

Inherits:
Item
  • Object
show all
Defined in:
lib/ruzbx/api/host.rb

Overview

Instance Attribute Summary

Attributes inherited from Item

#data

Class Method Summary collapse

Methods inherited from Item

#initialize

Constructor Details

This class inherits a constructor from Ruzbx::Api::Item

Class Method Details

.create(opts, &block) ⇒ Object

rubocop:disable Metrics/MethodLength



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruzbx/api/host.rb', line 9

def self.create(opts, &block)
  entity = Entity.build do
    rpc_method 'host.create'
    data params: {
      host: opts[:name],
      interfaces: [{ type: 1, main: 1, useip: 1, ip: opts[:ip],
                     dns: '', port: '10050' }],
      groups: opts[:groups],
      tags: [{ tag: 'creator', value: 'bot' }],
      templates: opts[:templates],
      macros: []
    }
    instance_eval(&block) if block_given?
  end
  new(entity.commit)
end