Class: SDM::Workflows
Overview
Workflows are the collection of rules that define the resources to which access can be requested, the users that can request that access, and the mechanism for approving those requests which can either be automatic approval or a set of users authorized to approve the requests.
See Workflow.
Instance Method Summary collapse
-
#create(workflow, deadline: nil) ⇒ Object
Create creates a new workflow and requires a name for the workflow.
-
#delete(id, deadline: nil) ⇒ Object
Delete deletes an existing workflow.
-
#get(id, deadline: nil) ⇒ Object
Get reads one workflow by ID.
-
#initialize(channel, parent) ⇒ Workflows
constructor
A new instance of Workflows.
-
#list(filter, *args, deadline: nil) ⇒ Object
Lists existing workflows.
-
#update(workflow, deadline: nil) ⇒ Object
Update updates an existing workflow.
Constructor Details
#initialize(channel, parent) ⇒ Workflows
Returns a new instance of Workflows.
8050 8051 8052 8053 8054 8055 8056 8057 |
# File 'lib/svc.rb', line 8050 def initialize(channel, parent) begin @stub = V1::Workflows::Stub.new(nil, nil, channel_override: channel) rescue => exception raise Plumbing::convert_error_to_porcelain(exception) end @parent = parent end |
Instance Method Details
#create(workflow, deadline: nil) ⇒ Object
Create creates a new workflow and requires a name for the workflow.
8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 |
# File 'lib/svc.rb', line 8060 def create( workflow, deadline: nil ) req = V1::WorkflowCreateRequest.new() req.workflow = Plumbing::convert_workflow_to_plumbing(workflow) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.create(req, metadata: @parent.("Workflows.Create", req), deadline: deadline) rescue => exception if (@parent.shouldRetry(tries, exception, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end resp = WorkflowCreateResponse.new() resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp.workflow = Plumbing::convert_workflow_to_porcelain(plumbing_response.workflow) resp end |
#delete(id, deadline: nil) ⇒ Object
Delete deletes an existing workflow.
8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 |
# File 'lib/svc.rb', line 8123 def delete( id, deadline: nil ) req = V1::WorkflowDeleteRequest.new() req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.delete(req, metadata: @parent.("Workflows.Delete", req), deadline: deadline) rescue => exception if (@parent.shouldRetry(tries, exception, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end resp = WorkflowDeleteResponse.new() resp.id = (plumbing_response.id) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp end |
#get(id, deadline: nil) ⇒ Object
Get reads one workflow by ID.
8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 |
# File 'lib/svc.rb', line 8089 def get( id, deadline: nil ) req = V1::WorkflowGetRequest.new() if not @parent.snapshot_time.nil? req. = V1::GetRequestMetadata.new() req..snapshot_at = @parent.snapshot_time end req.id = (id) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.get(req, metadata: @parent.("Workflows.Get", req), deadline: deadline) rescue => exception if (@parent.shouldRetry(tries, exception, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end resp = WorkflowGetResponse.new() resp. = Plumbing::(plumbing_response.) resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp.workflow = Plumbing::convert_workflow_to_porcelain(plumbing_response.workflow) resp end |
#list(filter, *args, deadline: nil) ⇒ Object
Lists existing workflows.
8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 |
# File 'lib/svc.rb', line 8181 def list( filter, *args, deadline: nil ) req = V1::WorkflowListRequest.new() req. = V1::ListRequestMetadata.new() if not @parent.page_limit.nil? req..limit = @parent.page_limit end if not @parent.snapshot_time.nil? req..snapshot_at = @parent.snapshot_time 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.("Workflows.List", req), deadline: deadline) rescue => exception if (@parent.shouldRetry(tries, exception, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end tries = 0 plumbing_response.workflows.each do |plumbing_item| g.yield Plumbing::convert_workflow_to_porcelain(plumbing_item) end break if plumbing_response..next_cursor == "" req..cursor = plumbing_response..next_cursor end } resp end |
#update(workflow, deadline: nil) ⇒ Object
Update updates an existing workflow.
8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 |
# File 'lib/svc.rb', line 8152 def update( workflow, deadline: nil ) req = V1::WorkflowUpdateRequest.new() req.workflow = Plumbing::convert_workflow_to_plumbing(workflow) tries = 0 plumbing_response = nil loop do begin plumbing_response = @stub.update(req, metadata: @parent.("Workflows.Update", req), deadline: deadline) rescue => exception if (@parent.shouldRetry(tries, exception, deadline)) tries + +sleep(@parent.exponentialBackoff(tries, deadline)) next end raise Plumbing::convert_error_to_porcelain(exception) end break end resp = WorkflowUpdateResponse.new() resp.rate_limit = Plumbing::(plumbing_response.rate_limit) resp.workflow = Plumbing::convert_workflow_to_porcelain(plumbing_response.workflow) resp end |