Module: Google::Cloud::Support::V2beta::CaseAttachmentService::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/support/v2beta/case_attachment_service/paths.rb

Overview

Path helper methods for the CaseAttachmentService API.

Instance Method Summary collapse

Instance Method Details

#attachment_path(organization: ) ⇒ ::String #attachment_path(project: ) ⇒ ::String

Create a fully-qualified Attachment resource string.

Overloads:

  • #attachment_path(organization: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/cases/{case}/attachments/{attachment_id}

    Parameters:

    • organization (String) (defaults to: )
    • case (String)
    • attachment_id (String)
  • #attachment_path(project: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/cases/{case}/attachments/{attachment_id}

    Parameters:

    • project (String) (defaults to: )
    • case (String)
    • attachment_id (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/google/cloud/support/v2beta/case_attachment_service/paths.rb', line 49

def attachment_path **args
  resources = {
    "attachment_id:case:organization" => (proc do |organization:, case:, attachment_id:|
      raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
      raise ::ArgumentError, "case cannot contain /" if binding.local_variable_get(:case).to_s.include? "/"

      "organizations/#{organization}/cases/#{binding.local_variable_get :case}/attachments/#{attachment_id}"
    end),
    "attachment_id:case:project" => (proc do |project:, case:, attachment_id:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "case cannot contain /" if binding.local_variable_get(:case).to_s.include? "/"

      "projects/#{project}/cases/#{binding.local_variable_get :case}/attachments/#{attachment_id}"
    end)
  }

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

#case_path(organization: ) ⇒ ::String #case_path(project: ) ⇒ ::String

Create a fully-qualified Case resource string.

Overloads:

  • #case_path(organization: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/cases/{case}

    Parameters:

    • organization (String) (defaults to: )
    • case (String)
  • #case_path(project: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/cases/{case}

    Parameters:

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

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/google/cloud/support/v2beta/case_attachment_service/paths.rb', line 90

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

      "organizations/#{organization}/cases/#{binding.local_variable_get :case}"
    end),
    "case:project" => (proc do |project:, case:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"

      "projects/#{project}/cases/#{binding.local_variable_get :case}"
    end)
  }

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