Class: SDM::AccountAttachments

Inherits:
Object
  • Object
show all
Defined in:
lib/svc.rb

Overview

AccountAttachments assign an account to a role.

Instance Method Summary collapse

Constructor Details

#initialize(host, insecure, parent) ⇒ AccountAttachments

Returns a new instance of AccountAttachments.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/svc.rb', line 29

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

Instance Method Details

#create(account_attachment, options: nil, deadline: nil) ⇒ Object

Create registers a new AccountAttachment.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/svc.rb', line 43

def create(
 \
,
            options:nil,
 deadline:nil)
    req = V1::AccountAttachmentCreateRequest.new()
			
    req. = Plumbing::()
    req.options = Plumbing::(options)
    tries = 0
    plumbing_response = nil
    loop do
        begin
            plumbing_response = @stub.create(req, metadata: @parent.('AccountAttachments.Create', req), deadline:deadline)
        rescue => exception
            if (@parent.shouldRetry(tries, exception))
                tries++
                @parent.jitterSleep(tries)
                next
            end
            raise Plumbing::convert_error_to_porcelain(exception)
        end
        break
    end

			
    resp = AccountAttachmentCreateResponse.new()
    resp.meta = Plumbing::(plumbing_response.meta)
    resp. = Plumbing::(plumbing_response.)
    resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
    resp
end

#delete(id, deadline: nil) ⇒ Object

Delete removes a AccountAttachment by ID.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/svc.rb', line 107

def delete(
id \
,
 deadline:nil)
    req = V1::AccountAttachmentDeleteRequest.new()
			
    req.id = (id)
    tries = 0
    plumbing_response = nil
    loop do
        begin
            plumbing_response = @stub.delete(req, metadata: @parent.('AccountAttachments.Delete', req), deadline:deadline)
        rescue => exception
            if (@parent.shouldRetry(tries, exception))
                tries++
                @parent.jitterSleep(tries)
                next
            end
            raise Plumbing::convert_error_to_porcelain(exception)
        end
        break
    end

			
    resp = AccountAttachmentDeleteResponse.new()
    resp.meta = Plumbing::(plumbing_response.meta)
    resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
    resp
end

#get(id, deadline: nil) ⇒ Object

Get reads one AccountAttachment by ID.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/svc.rb', line 76

def get(
id \
,
 deadline:nil)
    req = V1::AccountAttachmentGetRequest.new()
			
    req.id = (id)
    tries = 0
    plumbing_response = nil
    loop do
        begin
            plumbing_response = @stub.get(req, metadata: @parent.('AccountAttachments.Get', req), deadline:deadline)
        rescue => exception
            if (@parent.shouldRetry(tries, exception))
                tries++
                @parent.jitterSleep(tries)
                next
            end
            raise Plumbing::convert_error_to_porcelain(exception)
        end
        break
    end

			
    resp = AccountAttachmentGetResponse.new()
    resp.meta = Plumbing::(plumbing_response.meta)
    resp. = Plumbing::(plumbing_response.)
    resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
    resp
end

#list(filter, *args, deadline: nil) ⇒ Object

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



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/svc.rb', line 137

def list(
filter \
,
*args,
 deadline:nil)
    req = V1::AccountAttachmentListRequest.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.('AccountAttachments.List', req), deadline:deadline)
            rescue => exception
                if (@parent.shouldRetry(tries, exception))
                    tries++
                    @parent.jitterSleep(tries)
                    next
                end
                raise Plumbing::convert_error_to_porcelain(exception)
            end
            tries = 0
            plumbing_response..each do |plumbing_item|
                g.yield Plumbing::(plumbing_item)
            end
            break if plumbing_response.meta.next_cursor == ""
            req.meta.cursor = plumbing_response.meta.next_cursor
        end
    }
    resp
end