Sha256: d42dfc7b284bc9967eb26a861f1ddce2540b559f220b92f4c67a2019e40e1b13

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module Fog
  module Compute
    class DigitalOceanV2
      # noinspection RubyStringKeysInHashInspection
      class Real

        def create_ssh_key(name, public_key)
          create_options = {
            :name       => name,
            :public_key => public_key,
          }

          encoded_body = Fog::JSON.encode(create_options)

          request(
            :expects => [202],
            :headers => {
              'Content-Type' => "application/json; charset=UTF-8",
            },
            :method  => 'POST',
            :path    => '/v2/account/keys',
            :body    => encoded_body,
          )
        end
      end

      # noinspection RubyStringKeysInHashInspection
      class Mock
        def create_ssh_key(name, public_key)
          response        = Excon::Response.new
          response.status = 202

          response.body ={
            'ssh_key' => {
              'id'          => 512190,
              'fingerprint' => "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
              'public_key'  => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
              'name'        => "My SSH Public Key"
            }
          }

          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-1.35.0 lib/fog/digitalocean/requests/compute_v2/create_ssh_key.rb