Module: Google::Cloud::ResourceSettings::V1::ResourceSettingsService::Paths

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

Overview

Path helper methods for the ResourceSettingsService API.

Instance Method Summary collapse

Instance Method Details

#setting_path(project_number: , setting_name: ) ⇒ ::String #setting_path(folder: , setting_name: ) ⇒ ::String #setting_path(organization: , setting_name: ) ⇒ ::String

Create a fully-qualified Setting resource string.

Overloads:

  • #setting_path(project_number: , setting_name: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project_number}/settings/{setting_name}

    Parameters:

    • project_number (String) (defaults to: )
    • setting_name (String) (defaults to: )
  • #setting_path(folder: , setting_name: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/settings/{setting_name}

    Parameters:

    • folder (String) (defaults to: )
    • setting_name (String) (defaults to: )
  • #setting_path(organization: , setting_name: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/settings/{setting_name}

    Parameters:

    • organization (String) (defaults to: )
    • setting_name (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/resource_settings/v1/resource_settings_service/paths.rb', line 55

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

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

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

      "organizations/#{organization}/settings/#{setting_name}"
    end)
  }

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