Sha256: 2c24215dfc49ba09303ff27e8ed4955393da3615178fc357c912d75ed23ec742

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module NgrokAPI
  module Models
    class SSHCredential
      attr_reader :client,
        :attrs,
        :id,
        :uri,
        :created_at,
        :description,
        :metadata,
        :public_key,
        :acl

      def initialize(client: nil, attrs: {})
        @client = client
        @attrs = attrs
        @id = @attrs['id']
        @uri = @attrs['uri']
        @created_at = @attrs['created_at']
        @description = @attrs['description']
        @metadata = @attrs['metadata']
        @public_key = @attrs['public_key']
        @acl = @attrs['acl']
      end

      def ==(other)
        @attrs == other.attrs
      end

      def to_s
        @attrs.to_s
      end

      def to_h
        @attrs.to_h
      end

      ##
      # Delete an ssh_credential by ID
      #
      # https://ngrok.com/docs/api#api-ssh-credentials-delete
      def delete
        @client.delete(
          id: @id
        )
      end

      ##
      # Update attributes of an ssh_credential by ID
      #
      # https://ngrok.com/docs/api#api-ssh-credentials-update
      def update(
        description: nil,
        metadata: nil,
        acl: nil
      )
        @description = description if description
        @metadata = metadata if metadata
        @acl = acl if acl
        @client.update(
          id: @id,
          description: description,
          metadata: metadata,
          acl: acl
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ngrok-api-0.19.0 lib/ngrokapi/models/ssh_credential.rb