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.



6454
6455
6456
6457
6458
6459
6460
6461
# File 'lib/svc.rb', line 6454

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.



6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
# File 'lib/svc.rb', line 6464

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))
        tries + +@parent.jitterSleep(tries)
        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.



6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
# File 'lib/svc.rb', line 6527

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))
        tries + +@parent.jitterSleep(tries)
        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.



6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
# File 'lib/svc.rb', line 6493

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



6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
# File 'lib/svc.rb', line 6585

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::WorkflowListRequest.new()
  req.meta = V1::ListRequestMetadata.new()
  if @parent.page_limit > 0
    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))
          tries + +@parent.jitterSleep(tries)
          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.



6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
# File 'lib/svc.rb', line 6556

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))
        tries + +@parent.jitterSleep(tries)
        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