Module: Google::Cloud::Dialogflow::V2::Documents::Paths

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

Overview

Path helper methods for the Documents API.

Instance Method Summary collapse

Instance Method Details

#document_path(project: , knowledge_base: , document: ) ⇒ ::String #document_path(project: , location: , knowledge_base: , document: ) ⇒ ::String

Create a fully-qualified Document resource string.

Overloads:

  • #document_path(project: , knowledge_base: , document: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}

    Parameters:

    • project (String) (defaults to: )
    • knowledge_base (String) (defaults to: )
    • document (String) (defaults to: )
  • #document_path(project: , location: , knowledge_base: , document: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document}

    Parameters:

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

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/google/cloud/dialogflow/v2/documents/paths.rb', line 50

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

      "projects/#{project}/knowledgeBases/#{knowledge_base}/documents/#{document}"
    end),
    "document:knowledge_base:location:project" => (proc do |project:, location:, knowledge_base:, document:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
      raise ::ArgumentError, "knowledge_base cannot contain /" if knowledge_base.to_s.include? "/"

      "projects/#{project}/locations/#{location}/knowledgeBases/#{knowledge_base}/documents/#{document}"
    end)
  }

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

#knowledge_base_path(project: , knowledge_base: ) ⇒ ::String #knowledge_base_path(project: , location: , knowledge_base: ) ⇒ ::String

Create a fully-qualified KnowledgeBase resource string.

Overloads:

  • #knowledge_base_path(project: , knowledge_base: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/knowledgeBases/{knowledge_base}

    Parameters:

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

    The resource will be in the following format:

    projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}

    Parameters:

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

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/google/cloud/dialogflow/v2/documents/paths.rb', line 93

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

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

      "projects/#{project}/locations/#{location}/knowledgeBases/#{knowledge_base}"
    end)
  }

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