Class: EPP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/epp-client/client.rb,
lib/epp-client/testing.rb

Overview

Front facing EPP Client.

Establishes a connection to an EPP server and allows for sending commands to that EPP server.

Constant Summary collapse

DEFAULT_SERVICES =

Default Service URNs

Provided to make it easier for clients to add additional services to the default list.

Examples:

services = DEFAULT_SERVICES + %w(urn:ietf:params:xml:ns:secDNS-1.1)
EPP::Client.new('username','password','epp.example.com', :services => services)
[ Domain::NAMESPACE, Contact::NAMESPACE, Host::NAMESPACE ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag, passwd, host, options = {}) ⇒ Client

Create new instance of EPP::Client.

Parameters:

  • tag (String)

    EPP Tag

  • passwd (String)

    EPP Tag password

  • host (String)

    EPP Host address

  • options (Hash) (defaults to: {})

    Options

Options Hash (options):

  • :port (Integer)

    EPP Port number, default 700

  • :ssl_context (OpenSSL::SSL::SSLContext)

    For client certificate auth

  • :compatibility (Boolean)

    Compatibility mode, default false

  • :lang (String)

    EPP Language code, default ‘en’

  • :version (String)

    EPP protocol version, default ‘1.0’

  • :extensions (Array<String>)

    EPP Extension URNs

  • :services (Array<String>)

    EPP Service URNs

  • :address_family (String)

    ‘AF_INET’ or ‘AF_INET6’ or either of the appropriate socket constants. Will cause connections to be limited to this address family. Default try all addresses.



34
35
36
37
38
39
40
41
# File 'lib/epp-client/client.rb', line 34

def initialize(tag, passwd, host, options = {})
  @tag, @passwd, @host, @options = tag, passwd, host, options
  @conn = if options.delete(:compatibility) == true
    OldServer.new(tag, passwd, host, options)
  else
    Server.new(tag, passwd, host, options)
  end
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



43
44
45
# File 'lib/epp-client/client.rb', line 43

def host
  @host
end

#optionsObject (readonly)

Returns the value of attribute options.



43
44
45
# File 'lib/epp-client/client.rb', line 43

def options
  @options
end

#passwdObject (readonly)

Returns the value of attribute passwd.



43
44
45
# File 'lib/epp-client/client.rb', line 43

def passwd
  @passwd
end

#tagObject (readonly)

Returns the value of attribute tag.



43
44
45
# File 'lib/epp-client/client.rb', line 43

def tag
  @tag
end

Instance Method Details

#_last_errorResponseError

Deprecated.

Returns the last error received from a login or logout request

Returns:

  • (ResponseError)

    last error received from login/logout request



92
93
94
95
# File 'lib/epp-client/client.rb', line 92

def _last_error
  warn "The #{self.class}#_last_error method is deprecated, please call #last_error"
  last_error
end

#_last_requestRequest

Deprecated.

Returns the last request sent to the EPP server

Returns:

  • (Request)

    last request sent to the EPP server



60
61
62
63
# File 'lib/epp-client/client.rb', line 60

def _last_request
  warn "The #{self.class}#_last_request method is deprecated, please call #last_request"
  last_request
end

#_last_responseResponse

Deprecated.

Returns the last response received from the EPP server

Returns:

  • (Response)

    last response received from the EPP server



76
77
78
79
# File 'lib/epp-client/client.rb', line 76

def _last_response
  warn "The #{self.class}#_last_response method is deprecated, please call #last_response"
  last_response
end

#ack(msgID) ⇒ Object



147
148
149
150
# File 'lib/epp-client/client.rb', line 147

def ack(msgID)
  ack = EPP::Commands::Poll.new(msgID)
  command(ack)
end

#ack_prepare(msgID) ⇒ Object



45
46
47
48
# File 'lib/epp-client/testing.rb', line 45

def ack_prepare(msgID)
  ack = EPP::Commands::Poll.new(msgID)
  prepare_request(ack)
end

#check(payload, extension = nil) ⇒ Object



108
109
110
111
# File 'lib/epp-client/client.rb', line 108

def check(payload, extension = nil)
  check = EPP::Commands::Check.new(payload)
  command(check, extension)
end

#check_prepare(payload, extension = nil) ⇒ Object

Request Preparation Methods



6
7
8
9
# File 'lib/epp-client/testing.rb', line 6

def check_prepare(payload, extension = nil)
  check = EPP::Commands::Check.new(payload)
  prepare_request(check, extension)
end

#compatibility?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/epp-client/client.rb', line 45

def compatibility?
  @conn.is_a?(OldServer)
end

#create(payload, extension = nil) ⇒ Object



113
114
115
116
# File 'lib/epp-client/client.rb', line 113

def create(payload, extension = nil)
  create = EPP::Commands::Create.new(payload)
  command(create, extension)
end

#create_prepare(payload, extension = nil) ⇒ Object



11
12
13
14
# File 'lib/epp-client/testing.rb', line 11

def create_prepare(payload, extension = nil)
  create = EPP::Commands::Create.new(payload)
  prepare_request(create, extension)
end

#delete(payload, extension = nil) ⇒ Object



118
119
120
121
# File 'lib/epp-client/client.rb', line 118

def delete(payload, extension = nil)
  delete = EPP::Commands::Delete.new(payload)
  command(delete, extension)
end

#delete_prepare(payload, extension = nil) ⇒ Object



16
17
18
19
# File 'lib/epp-client/testing.rb', line 16

def delete_prepare(payload, extension = nil)
  delete = EPP::Commands::Delete.new(payload)
  prepare_request(delete, extension)
end

#greetingObject



97
98
99
# File 'lib/epp-client/client.rb', line 97

def greeting
  @conn.greeting
end

#helloObject

Send hello command



102
103
104
105
106
# File 'lib/epp-client/client.rb', line 102

def hello
  @conn.connection do
    @conn.hello
  end
end

#info(payload, extension = nil) ⇒ Object



123
124
125
126
# File 'lib/epp-client/client.rb', line 123

def info(payload, extension = nil)
  info = EPP::Commands::Info.new(payload)
  command(info, extension)
end

#info_prepare(payload, extension = nil) ⇒ Object



21
22
23
24
# File 'lib/epp-client/testing.rb', line 21

def info_prepare(payload, extension = nil)
  info = EPP::Commands::Info.new(payload)
  prepare_request(info, extension)
end

#last_errorResponseError

Returns the last error received from a login or logout request

Returns:

  • (ResponseError)

    last error received from login/logout request



84
85
86
# File 'lib/epp-client/client.rb', line 84

def last_error
  @conn.last_error
end

#last_requestRequest

Returns the last request sent to the EPP server

Returns:

  • (Request)

    last request sent to the EPP server



52
53
54
# File 'lib/epp-client/client.rb', line 52

def last_request
  @conn.last_request
end

#last_responseResponse

Returns the last response received from the EPP server

Returns:

  • (Response)

    last response received from the EPP server



68
69
70
# File 'lib/epp-client/client.rb', line 68

def last_response
  @conn.last_response
end

#load_response(xml_data) ⇒ Object

Response Preparation Methods



55
56
57
# File 'lib/epp-client/testing.rb', line 55

def load_response(xml_data)
  EPP::Response.new(xml_data)
end

#pollObject



143
144
145
146
# File 'lib/epp-client/client.rb', line 143

def poll
  poll = EPP::Commands::Poll.new
  command(poll)
end

#poll_prepareObject



41
42
43
44
# File 'lib/epp-client/testing.rb', line 41

def poll_prepare
  poll = EPP::Commands::Poll.new
  prepare_request(poll)
end

#prepare_request(cmd, extension = nil) ⇒ Object



50
51
52
# File 'lib/epp-client/testing.rb', line 50

def prepare_request(cmd, extension = nil)
  @conn.prepare_request(cmd, extension)
end

#renew(payload, extension = nil) ⇒ Object



128
129
130
131
# File 'lib/epp-client/client.rb', line 128

def renew(payload, extension = nil)
  renew = EPP::Commands::Renew.new(payload)
  command(renew, extension)
end

#renew_prepare(payload, extension = nil) ⇒ Object



26
27
28
29
# File 'lib/epp-client/testing.rb', line 26

def renew_prepare(payload, extension = nil)
  renew = EPP::Commands::Renew.new(payload)
  prepare_request(renew, extension)
end

#transfer(op, payload, extension = nil) ⇒ Object



133
134
135
136
# File 'lib/epp-client/client.rb', line 133

def transfer(op, payload, extension = nil)
  transfer = EPP::Commands::Transfer.new(op, payload)
  command(transfer, extension)
end

#transfer_prepare(op, payload, extension = nil) ⇒ Object



31
32
33
34
# File 'lib/epp-client/testing.rb', line 31

def transfer_prepare(op, payload, extension = nil)
  transfer = EPP::Commands::Transfer.new(op, payload)
  prepare_request(transfer, extension)
end

#update(payload, extension = nil) ⇒ Object



138
139
140
141
# File 'lib/epp-client/client.rb', line 138

def update(payload, extension = nil)
  update = EPP::Commands::Update.new(payload)
  command(update, extension)
end

#update_prepare(payload, extension = nil) ⇒ Object



36
37
38
39
# File 'lib/epp-client/testing.rb', line 36

def update_prepare(payload, extension = nil)
  update = EPP::Commands::Update.new(payload)
  prepare_request(update, extension)
end