Module: Google::Cloud::Monitoring::V3::GroupService::Paths

Extended by:
Paths
Included in:
Client, Paths
Defined in:
lib/google/cloud/monitoring/v3/group_service/paths.rb

Overview

Path helper methods for the GroupService API.

Instance Method Summary collapse

Instance Method Details

#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)


37
38
39
# File 'lib/google/cloud/monitoring/v3/group_service/paths.rb', line 37

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

#group_path(project: , group: ) ⇒ ::String #group_path(organization: , group: ) ⇒ ::String #group_path(folder: , group: ) ⇒ ::String

Create a fully-qualified Group resource string.

Overloads:

  • #group_path(project: , group: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/groups/{group}

    Parameters:

    • project (String) (defaults to: )
    • group (String) (defaults to: )
  • #group_path(organization: , group: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/groups/{group}

    Parameters:

    • organization (String) (defaults to: )
    • group (String) (defaults to: )
  • #group_path(folder: , group: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/groups/{group}

    Parameters:

    • folder (String) (defaults to: )
    • group (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/google/cloud/monitoring/v3/group_service/paths.rb', line 69

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

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

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

      "folders/#{folder}/groups/#{group}"
    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)


103
104
105
# File 'lib/google/cloud/monitoring/v3/group_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/monitoring/v3/group_service/paths.rb', line 117

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

#workspace_path(project: ) ⇒ ::String #workspace_path(workspace: ) ⇒ ::String

Create a fully-qualified Workspace resource string.

Overloads:

  • #workspace_path(project: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}

    Parameters:

    • project (String) (defaults to: )
  • #workspace_path(workspace: ) ⇒ ::String

    The resource will be in the following format:

    workspaces/{workspace}

    Parameters:

    • workspace (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/google/cloud/monitoring/v3/group_service/paths.rb', line 139

def workspace_path **args
  resources = {
    "project" => (proc do |project:|
      "projects/#{project}"
    end),
    "workspace" => (proc do |workspace:|
      "workspaces/#{workspace}"
    end)
  }

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