Module: Google::Cloud::PolicySimulator::V1::Simulator::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/policy_simulator/v1/simulator/paths.rb

Overview

Path helper methods for the Simulator API.

Instance Method Summary collapse

Instance Method Details

#replay_path(project: , location: , replay: ) ⇒ ::String #replay_path(folder: , location: , replay: ) ⇒ ::String #replay_path(organization: , location: , replay: ) ⇒ ::String

Create a fully-qualified Replay resource string.

Overloads:

  • #replay_path(project: , location: , replay: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/replays/{replay}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • replay (String) (defaults to: )
  • #replay_path(folder: , location: , replay: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/locations/{location}/replays/{replay}

    Parameters:

    • folder (String) (defaults to: )
    • location (String) (defaults to: )
    • replay (String) (defaults to: )
  • #replay_path(organization: , location: , replay: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/locations/{location}/replays/{replay}

    Parameters:

    • organization (String) (defaults to: )
    • location (String) (defaults to: )
    • replay (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/google/cloud/policy_simulator/v1/simulator/paths.rb', line 58

def replay_path **args
  resources = {
    "location:project:replay" => (proc do |project:, location:, replay:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"

      "projects/#{project}/locations/#{location}/replays/#{replay}"
    end),
    "folder:location:replay" => (proc do |folder:, location:, replay:|
      raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"

      "folders/#{folder}/locations/#{location}/replays/#{replay}"
    end),
    "location:organization:replay" => (proc do |organization:, location:, replay:|
      raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"

      "organizations/#{organization}/locations/#{location}/replays/#{replay}"
    end)
  }

  resource = resources[args.keys.sort.join(":")]
  raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
  resource.call(**args)
end