Module: Google::Cloud::EssentialContacts::V1::EssentialContactsService::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/essential_contacts/v1/essential_contacts_service/paths.rb

Overview

Path helper methods for the EssentialContactsService API.

Instance Method Summary collapse

Instance Method Details

#contact_path(project: , contact: ) ⇒ ::String #contact_path(folder: , contact: ) ⇒ ::String #contact_path(organization: , contact: ) ⇒ ::String

Create a fully-qualified Contact resource string.

Overloads:

  • #contact_path(project: , contact: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/contacts/{contact}

    Parameters:

    • project (String) (defaults to: )
    • contact (String) (defaults to: )
  • #contact_path(folder: , contact: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/contacts/{contact}

    Parameters:

    • folder (String) (defaults to: )
    • contact (String) (defaults to: )
  • #contact_path(organization: , contact: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/contacts/{contact}

    Parameters:

    • organization (String) (defaults to: )
    • contact (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/google/cloud/essential_contacts/v1/essential_contacts_service/paths.rb', line 55

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

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

      "folders/#{folder}/contacts/#{contact}"
    end),
    "contact:organization" => (proc do |organization:, contact:|
      raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"

      "organizations/#{organization}/contacts/#{contact}"
    end)
  }

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

#folder_path(folder:) ⇒ ::String

Create a fully-qualified Folder resource string.

The resource will be in the following format:

folders/{folder}

Parameters:

  • folder (String)

Returns:

  • (::String)


89
90
91
# File 'lib/google/cloud/essential_contacts/v1/essential_contacts_service/paths.rb', line 89

def folder_path folder:
  "folders/#{folder}"
end

#organization_path(organization:) ⇒ ::String

Create a fully-qualified Organization resource string.

The resource will be in the following format:

organizations/{organization}

Parameters:

  • organization (String)

Returns:

  • (::String)


103
104
105
# File 'lib/google/cloud/essential_contacts/v1/essential_contacts_service/paths.rb', line 103

def organization_path organization:
  "organizations/#{organization}"
end

#project_path(project:) ⇒ ::String

Create a fully-qualified Project resource string.

The resource will be in the following format:

projects/{project}

Parameters:

  • project (String)

Returns:

  • (::String)


117
118
119
# File 'lib/google/cloud/essential_contacts/v1/essential_contacts_service/paths.rb', line 117

def project_path project:
  "projects/#{project}"
end