Class: SDM::ApprovalWorkflows

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

Overview

ApprovalWorkflows are the mechanism by which requests for access can be viewed by authorized approvers and be approved or denied.

See ApprovalWorkflow.

Instance Method Summary collapse

Constructor Details

#initialize(channel, parent) ⇒ ApprovalWorkflows

Returns a new instance of ApprovalWorkflows.



1751
1752
1753
1754
1755
1756
1757
1758
# File 'lib/svc.rb', line 1751

def initialize(channel, parent)
  begin
    @stub = V1::ApprovalWorkflows::Stub.new(nil, nil, channel_override: channel)
  rescue => exception
    raise Plumbing::convert_error_to_porcelain(exception)
  end
  @parent = parent
end

Instance Method Details

#create(approval_workflow, deadline: nil) ⇒ Object

Create creates a new approval workflow and requires a name and approval mode for the approval workflow.



1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
# File 'lib/svc.rb', line 1761

def create(
  approval_workflow,
  deadline: nil
)
  req = V1::ApprovalWorkflowCreateRequest.new()

  req.approval_workflow = Plumbing::convert_approval_workflow_to_plumbing(approval_workflow)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.create(req, metadata: @parent.("ApprovalWorkflows.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 = ApprovalWorkflowCreateResponse.new()
  resp.approval_workflow = Plumbing::convert_approval_workflow_to_porcelain(plumbing_response.approval_workflow)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#delete(id, deadline: nil) ⇒ Object

Delete deletes an existing approval workflow.



1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
# File 'lib/svc.rb', line 1824

def delete(
  id,
  deadline: nil
)
  req = V1::ApprovalWorkflowDeleteRequest.new()

  req.id = (id)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.delete(req, metadata: @parent.("ApprovalWorkflows.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 = ApprovalWorkflowDeleteResponse.new()
  resp.id = (plumbing_response.id)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

#get(id, deadline: nil) ⇒ Object

Get reads one approval workflow by ID.



1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
# File 'lib/svc.rb', line 1790

def get(
  id,
  deadline: nil
)
  req = V1::ApprovalWorkflowGetRequest.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.("ApprovalWorkflows.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 = ApprovalWorkflowGetResponse.new()
  resp.approval_workflow = Plumbing::convert_approval_workflow_to_porcelain(plumbing_response.approval_workflow)
  resp.meta = Plumbing::(plumbing_response.meta)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end

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

Lists existing approval workflows.



1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
# File 'lib/svc.rb', line 1882

def list(
  filter,
  *args,
  deadline: nil
)
  req = V1::ApprovalWorkflowListRequest.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.("ApprovalWorkflows.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.approval_workflows.each do |plumbing_item|
        g.yield Plumbing::convert_approval_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(approval_workflow, deadline: nil) ⇒ Object

Update updates an existing approval workflow.



1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
# File 'lib/svc.rb', line 1853

def update(
  approval_workflow,
  deadline: nil
)
  req = V1::ApprovalWorkflowUpdateRequest.new()

  req.approval_workflow = Plumbing::convert_approval_workflow_to_plumbing(approval_workflow)
  tries = 0
  plumbing_response = nil
  loop do
    begin
      plumbing_response = @stub.update(req, metadata: @parent.("ApprovalWorkflows.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 = ApprovalWorkflowUpdateResponse.new()
  resp.approval_workflow = Plumbing::convert_approval_workflow_to_porcelain(plumbing_response.approval_workflow)
  resp.rate_limit = Plumbing::(plumbing_response.rate_limit)
  resp
end