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.
7835 7836 7837 7838 7839 7840 7841 7842 |
# File 'lib/svc.rb', line 7835 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.
7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 |
# File 'lib/svc.rb', line 7845 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.
7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 |
# File 'lib/svc.rb', line 7908 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.
7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 |
# File 'lib/svc.rb', line 7874 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.
7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 |
# File 'lib/svc.rb', line 7966 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.
7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 |
# File 'lib/svc.rb', line 7937 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 |