Module: Google::Cloud::Dialogflow::V2::Intents::Paths

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

Overview

Path helper methods for the Intents 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/intents/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

#context_path(project: , session: , context: ) ⇒ ::String #context_path(project: , environment: , user: , session: , context: ) ⇒ ::String #context_path(project: , location: , session: , context: ) ⇒ ::String #context_path(project: , location: , environment: , user: , session: , context: ) ⇒ ::String

Create a fully-qualified Context resource string.

Overloads:

  • #context_path(project: , session: , context: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/agent/sessions/{session}/contexts/{context}

    Parameters:

    • project (String) (defaults to: )
    • session (String) (defaults to: )
    • context (String) (defaults to: )
  • #context_path(project: , environment: , user: , session: , context: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context}

    Parameters:

    • project (String) (defaults to: )
    • environment (String) (defaults to: )
    • user (String) (defaults to: )
    • session (String) (defaults to: )
    • context (String) (defaults to: )
  • #context_path(project: , location: , session: , context: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • session (String) (defaults to: )
    • context (String) (defaults to: )
  • #context_path(project: , location: , environment: , user: , session: , context: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • environment (String) (defaults to: )
    • user (String) (defaults to: )
    • session (String) (defaults to: )
    • context (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/google/cloud/dialogflow/v2/intents/paths.rb', line 109

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

      "projects/#{project}/agent/sessions/#{session}/contexts/#{context}"
    end),
    "context:environment:project:session:user" => (proc do |project:, environment:, user:, session:, context:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "environment cannot contain /" if environment.to_s.include? "/"
      raise ::ArgumentError, "user cannot contain /" if user.to_s.include? "/"
      raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"

      "projects/#{project}/agent/environments/#{environment}/users/#{user}/sessions/#{session}/contexts/#{context}"
    end),
    "context:location:project:session" => (proc do |project:, location:, session:, context:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
      raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"

      "projects/#{project}/locations/#{location}/agent/sessions/#{session}/contexts/#{context}"
    end),
    "context:environment:location:project:session:user" => (proc do |project:, location:, environment:, user:, session:, context:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
      raise ::ArgumentError, "environment cannot contain /" if environment.to_s.include? "/"
      raise ::ArgumentError, "user cannot contain /" if user.to_s.include? "/"
      raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"

      "projects/#{project}/locations/#{location}/agent/environments/#{environment}/users/#{user}/sessions/#{session}/contexts/#{context}"
    end)
  }

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

#intent_path(project: , intent: ) ⇒ ::String #intent_path(project: , location: , intent: ) ⇒ ::String

Create a fully-qualified Intent resource string.

Overloads:

  • #intent_path(project: , intent: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/agent/intents/{intent}

    Parameters:

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

    The resource will be in the following format:

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

    Parameters:

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

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/google/cloud/dialogflow/v2/intents/paths.rb', line 169

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

      "projects/#{project}/agent/intents/#{intent}"
    end),
    "intent:location:project" => (proc do |project:, location:, intent:|
      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/intents/#{intent}"
    end)
  }

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