Module: Google::Cloud::Dialogflow::V2::Versions::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/dialogflow/v2/versions/paths.rb

Overview

Path helper methods for the Versions API.

Instance Method Summary collapse

Instance Method Details

#agent_path(project: ) ⇒ ::String #agent_path(project: , location: ) ⇒ ::String

Create a fully-qualified Agent resource string.

Overloads:

  • #agent_path(project: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/agent

    Parameters:

    • project (String) (defaults to: )
  • #agent_path(project: , location: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/agent

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/google/cloud/dialogflow/v2/versions/paths.rb', line 46

def agent_path **args
  resources = {
    "project" => (proc do |project:|
      "projects/#{project}/agent"
    end),
    "location:project" => (proc do |project:, location:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"

      "projects/#{project}/locations/#{location}/agent"
    end)
  }

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

#version_path(project: , version: ) ⇒ ::String #version_path(project: , location: , version: ) ⇒ ::String

Create a fully-qualified Version resource string.

Overloads:

  • #version_path(project: , version: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/agent/versions/{version}

    Parameters:

    • project (String) (defaults to: )
    • version (String) (defaults to: )
  • #version_path(project: , location: , version: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/agent/versions/{version}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • version (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/google/cloud/dialogflow/v2/versions/paths.rb', line 84

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

      "projects/#{project}/agent/versions/#{version}"
    end),
    "location:project:version" => (proc do |project:, location:, version:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"

      "projects/#{project}/locations/#{location}/agent/versions/#{version}"
    end)
  }

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