class SDM::AccountGrants

AccountGrants connect a resource directly to an account, giving the account the permission to connect to that resource.

def create(

Create registers a new AccountGrant.
def create(
grant \
e:nil)
    req = V1::AccountGrantCreateRequest.new()
    req.account_grant = Plumbing::account_grant_to_plumbing(account_grant)
    tries = 0
    plumbing_response = nil
    loop do
        begin
            plumbing_response = @stub.create(req, metadata: @parent.get_metadata('AccountGrants.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 = AccountGrantCreateResponse.new()
    resp.meta = Plumbing::create_response_metadata_to_porcelain(plumbing_response.meta)
    resp.account_grant = Plumbing::account_grant_to_porcelain(plumbing_response.account_grant)
    resp.rate_limit = Plumbing::rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
    resp
end

def delete(

Delete removes a AccountGrant by ID.
def delete(
e:nil)
    req = V1::AccountGrantDeleteRequest.new()
    req.id = id
    tries = 0
    plumbing_response = nil
    loop do
        begin
            plumbing_response = @stub.delete(req, metadata: @parent.get_metadata('AccountGrants.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 = AccountGrantDeleteResponse.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

def get(

Get reads one AccountGrant by ID.
def get(
e:nil)
    req = V1::AccountGrantGetRequest.new()
    req.id = id
    tries = 0
    plumbing_response = nil
    loop do
        begin
            plumbing_response = @stub.get(req, metadata: @parent.get_metadata('AccountGrants.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 = AccountGrantGetResponse.new()
    resp.meta = Plumbing::get_response_metadata_to_porcelain(plumbing_response.meta)
    resp.account_grant = Plumbing::account_grant_to_porcelain(plumbing_response.account_grant)
    resp.rate_limit = Plumbing::rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)
    resp
end

def initialize(host, insecure, parent)

def initialize(host, insecure, parent)
    begin
        if insecure
            @stub = V1::AccountGrants::Stub.new(host, :this_channel_is_insecure)
        else
            cred = GRPC::Core::ChannelCredentials.new()
            @stub = V1::AccountGrants::Stub.new(host, cred)
        end
    rescue => exception
        raise Plumbing::error_to_porcelain(exception)
    end
    @parent = parent
end

def list(

List gets a list of AccountGrants matching a given set of criteria.
def list(

e:nil)
    req = V1::AccountGrantListRequest.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('AccountGrants.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.account_grants.each do |plumbing_item|
                g.yield Plumbing::account_grant_to_porcelain(plumbing_item)
            end
            break if plumbing_response.meta.next_cursor == ""
            req.meta.cursor = plumbing_response.meta.next_cursor
        end
    }
    resp
end