Module: Google::Cloud::Dialogflow::V2::Sessions::Paths

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

Overview

Path helper methods for the Sessions API.

Instance Method Summary collapse

Instance Method Details

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

Create a fully-qualified Context resource string.

The resource will be in the following format:

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

Parameters:

  • project (String)
  • session (String)
  • context (String)

Returns:

  • (String)

Raises:

  • (ArgumentError)


39
40
41
42
43
44
# File 'lib/google/cloud/dialogflow/v2/sessions/paths.rb', line 39

def context_path 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

#session_entity_type_path(project:, session:, entity_type:) ⇒ String

Create a fully-qualified SessionEntityType resource string.

The resource will be in the following format:

projects/{project}/agent/sessions/{session}/entityTypes/{entity_type}

Parameters:

  • project (String)
  • session (String)
  • entity_type (String)

Returns:

  • (String)

Raises:

  • (ArgumentError)


99
100
101
102
103
104
# File 'lib/google/cloud/dialogflow/v2/sessions/paths.rb', line 99

def session_entity_type_path project:, session:, entity_type:
  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}/entityTypes/#{entity_type}"
end

#session_path(project: , location: , session: ) ⇒ String #session_path(project: , session: ) ⇒ String

Create a fully-qualified Session resource string.

Overloads:

  • #session_path(project: , location: , session: ) ⇒ String

    The resource will be in the following format:

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

    Parameters:

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

    The resource will be in the following format:

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

    Parameters:

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

Returns:

  • (String)

Raises:

  • (ArgumentError)


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/google/cloud/dialogflow/v2/sessions/paths.rb', line 67

def session_path **args
  resources = {
    "location:project:session" => (proc do |project:, location:, session:|
      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/sessions/#{session}"
    end),
    "project:session"          => (proc do |project:, session:|
      raise ArgumentError, "project cannot contain /" if project.to_s.include? "/"

      "projects/#{project}/agent/sessions/#{session}"
    end)
  }

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