Class: SDM::Workflows

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/svc.rb

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

Constructor Details

#initialize(channel, parent) ⇒ Workflows

Returns a new instance of Workflows.



6989
6990
6991
6992
6993
6994
6995
6996
# File 'lib/svc.rb', line 6989

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.



6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
# File 'lib/svc.rb', line 6999

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.



7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
# File 'lib/svc.rb', line 7062

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.



7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
# File 'lib/svc.rb', line 7028

def get(
  id,
  deadline: nil
)
  req = V1::WorkflowGetRequest.new()
  if not @parent.snapshot_time.nil?
    req.meta = V1::.new()
    req.meta.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.meta = Plumbing::(plumbing_response.meta)
  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.



7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
# File 'lib/svc.rb', line 7120

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::WorkflowListRequest.new()
  req.meta = V1::.new()
  if not @parent.page_limit.nil?
    req.meta.limit = @parent.page_limit
  end
  if not @parent.snapshot_time.nil?
    req.meta.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.meta.next_cursor == ""
      req.meta.cursor = plumbing_response.meta.next_cursor
    end
  }
  resp
end

#update(workflow, deadline: nil) ⇒ Object

Update updates an existing workflow.



7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
# File 'lib/svc.rb', line 7091

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