Method: Vinyldns::API#initialize
- Defined in:
- lib/vinyldns/api.rb
#initialize(method, region = 'us-east-1', api_url = ENV['VINYLDNS_API_URL'], content_type = 'application/x-www-form-urlencoded') ⇒ API
Required arguments:
-
method
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vinyldns/api.rb', line 22 def initialize(method, region = 'us-east-1', api_url = ENV['VINYLDNS_API_URL'], content_type = 'application/x-www-form-urlencoded') @api_url = api_url @method = method.upcase raise(ArgumentError, 'Not a valid http request method') unless %w[GET HEAD POST PUT DELETE TRACE OPTIONS CONNECT PATCH].include?(@method) @region = region if @method == 'GET' @content_type = content_type elsif @method == 'POST' || @method == 'PUT' @content_type = 'application/json' end # Generate a signed header for our HTTP requests # http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html @signer = Aws::Sigv4::Signer.new( service: 'VinylDNS', region: 'us-east-1', access_key_id: ENV['VINYLDNS_ACCESS_KEY_ID'], secret_access_key: ENV['VINYLDNS_SECRET_ACCESS_KEY'], apply_checksum_header: false # Required for posting body in make_request : http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html : If the 'X-Amz-Content-Sha256' header is set, the :body is optional and will not be read. ) end |