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.



5397
5398
5399
5400
5401
5402
5403
5404
# File 'lib/svc.rb', line 5397

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.



5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
# File 'lib/svc.rb', line 5407

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.



5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
# File 'lib/svc.rb', line 5470

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.



5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
# File 'lib/svc.rb', line 5436

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.



5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
# File 'lib/svc.rb', line 5528

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.



5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
# File 'lib/svc.rb', line 5499

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