Module: Google::Cloud::Logging::V2::LoggingService::Paths

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

Overview

Path helper methods for the LoggingService API.

Instance Method Summary collapse

Instance Method Details

#billing_account_path(billing_account:) ⇒ ::String

Create a fully-qualified BillingAccount resource string.

The resource will be in the following format:

billingAccounts/{billing_account}

Parameters:

  • billing_account (String)

Returns:

  • (::String)


37
38
39
# File 'lib/google/cloud/logging/v2/logging_service/paths.rb', line 37

def  billing_account:
  "billingAccounts/#{}"
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)


51
52
53
# File 'lib/google/cloud/logging/v2/logging_service/paths.rb', line 51

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

#log_path(project: , log: ) ⇒ ::String #log_path(organization: , log: ) ⇒ ::String #log_path(folder: , log: ) ⇒ ::String #log_path(billing_account: , log: ) ⇒ ::String

Create a fully-qualified Log resource string.

Overloads:

  • #log_path(project: , log: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/logs/{log}

    Parameters:

    • project (String) (defaults to: )
    • log (String) (defaults to: )
  • #log_path(organization: , log: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/logs/{log}

    Parameters:

    • organization (String) (defaults to: )
    • log (String) (defaults to: )
  • #log_path(folder: , log: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/logs/{log}

    Parameters:

    • folder (String) (defaults to: )
    • log (String) (defaults to: )
  • #log_path(billing_account: , log: ) ⇒ ::String

    The resource will be in the following format:

    billingAccounts/{billing_account}/logs/{log}

    Parameters:

    • billing_account (String) (defaults to: )
    • log (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/google/cloud/logging/v2/logging_service/paths.rb', line 91

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

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

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

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

      "billingAccounts/#{}/logs/#{log}"
    end)
  }

  resource = resources[args.keys.sort.join(":")]
  raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
  resource.call(**args)
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)


130
131
132
# File 'lib/google/cloud/logging/v2/logging_service/paths.rb', line 130

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)


144
145
146
# File 'lib/google/cloud/logging/v2/logging_service/paths.rb', line 144

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