class SDM::Nodes

Nodes make up the strongDM network, and allow your users to connect securely to your resources. There are two types of nodes:

  1. *Relay:* creates connectivity to your datasources, while maintaining the egress-only nature of your firewall

  2. *Gateways:* a relay that also listens for connections from strongDM clients

Public Class Methods

new(host, insecure, parent) click to toggle source
# File lib/svc.rb, line 504
def initialize(host, insecure, parent)
    begin
        if insecure
            @stub = V1::Nodes::Stub.new(host, :this_channel_is_insecure)
        else
            cred = GRPC::Core::ChannelCredentials.new()
            @stub = V1::Nodes::Stub.new(host, cred)
        end
    rescue => exception
        raise Plumbing::error_to_porcelain(exception)
    end
    @parent = parent
end

Public Instance Methods

create( node \ , deadline:nil) click to toggle source

Create registers a new Node.

# File lib/svc.rb, line 518
        def create(
node \
,
 deadline:nil)
            req = V1::NodeCreateRequest.new()
                        
            req.node = Plumbing::node_to_plumbing(node)
            tries = 0
            plumbing_response = nil
            loop do
                begin
                    plumbing_response = @stub.create(req, metadata: @parent.get_metadata('Nodes.Create', req), deadline:deadline)
                rescue => exception
                    if (@parent.shouldRetry(tries, exception))
                        tries++
                        @parent.jitterSleep(tries)
                        next
                    end
                    raise Plumbing::error_to_porcelain(exception)
                end
                break
            end

                        
            resp = NodeCreateResponse.new()
            resp.meta = Plumbing::create_response_metadata_to_porcelain(plumbing_response.meta)
            resp.node = Plumbing::node_to_porcelain(plumbing_response.node)
            resp.token = plumbing_response.token
            resp.rate_limit = Plumbing::rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
            resp
        end
delete( id \ , deadline:nil) click to toggle source

Delete removes a Node by ID.

# File lib/svc.rb, line 612
        def delete(
id \
,
 deadline:nil)
            req = V1::NodeDeleteRequest.new()
                        
            req.id = id
            tries = 0
            plumbing_response = nil
            loop do
                begin
                    plumbing_response = @stub.delete(req, metadata: @parent.get_metadata('Nodes.Delete', req), deadline:deadline)
                rescue => exception
                    if (@parent.shouldRetry(tries, exception))
                        tries++
                        @parent.jitterSleep(tries)
                        next
                    end
                    raise Plumbing::error_to_porcelain(exception)
                end
                break
            end

                        
            resp = NodeDeleteResponse.new()
            resp.meta = Plumbing::delete_response_metadata_to_porcelain(plumbing_response.meta)
            resp.rate_limit = Plumbing::rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
            resp
        end
get( id \ , deadline:nil) click to toggle source

Get reads one Node by ID.

# File lib/svc.rb, line 550
        def get(
id \
,
 deadline:nil)
            req = V1::NodeGetRequest.new()
                        
            req.id = id
            tries = 0
            plumbing_response = nil
            loop do
                begin
                    plumbing_response = @stub.get(req, metadata: @parent.get_metadata('Nodes.Get', req), deadline:deadline)
                rescue => exception
                    if (@parent.shouldRetry(tries, exception))
                        tries++
                        @parent.jitterSleep(tries)
                        next
                    end
                    raise Plumbing::error_to_porcelain(exception)
                end
                break
            end

                        
            resp = NodeGetResponse.new()
            resp.meta = Plumbing::get_response_metadata_to_porcelain(plumbing_response.meta)
            resp.node = Plumbing::node_to_porcelain(plumbing_response.node)
            resp.rate_limit = Plumbing::rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
            resp
        end
list( filter \ , *args, deadline:nil) click to toggle source

List gets a list of Nodes matching a given set of criteria.

# File lib/svc.rb, line 642
        def list(
filter \
,
*args,
 deadline:nil)
            req = V1::NodeListRequest.new()
            req.meta = V1::ListRequestMetadata.new()
            page_size_option = @parent._test_options['PageSize']
            if page_size_option.is_a? Integer
                req.meta.limit = page_size_option
            end
                        
            req.filter = Plumbing::quote_filter_args(filter, *args)
            resp = Enumerator::Generator.new { |g|
                tries = 0
                loop do
                    begin
                        plumbing_response = @stub.list(req, metadata: @parent.get_metadata('Nodes.List', req), deadline:deadline)
                    rescue => exception
                        if (@parent.shouldRetry(tries, exception))
                            tries++
                            @parent.jitterSleep(tries)
                            next
                        end
                        raise Plumbing::error_to_porcelain(exception)
                    end
                    tries = 0
                    plumbing_response.nodes.each do |plumbing_item|
                        g.yield Plumbing::node_to_porcelain(plumbing_item)
                    end
                    break if plumbing_response.meta.next_cursor == ""
                    req.meta.cursor = plumbing_response.meta.next_cursor
                end
            }
            resp
        end
update( node \ , deadline:nil) click to toggle source

Update patches a Node by ID.

# File lib/svc.rb, line 581
        def update(
node \
,
 deadline:nil)
            req = V1::NodeUpdateRequest.new()
                        
            req.node = Plumbing::node_to_plumbing(node)
            tries = 0
            plumbing_response = nil
            loop do
                begin
                    plumbing_response = @stub.update(req, metadata: @parent.get_metadata('Nodes.Update', req), deadline:deadline)
                rescue => exception
                    if (@parent.shouldRetry(tries, exception))
                        tries++
                        @parent.jitterSleep(tries)
                        next
                    end
                    raise Plumbing::error_to_porcelain(exception)
                end
                break
            end

                        
            resp = NodeUpdateResponse.new()
            resp.meta = Plumbing::update_response_metadata_to_porcelain(plumbing_response.meta)
            resp.node = Plumbing::node_to_porcelain(plumbing_response.node)
            resp.rate_limit = Plumbing::rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
            resp
        end