Method: Google::Cloud::Monitoring::V3::MetricService::Paths#metric_descriptor_path

Defined in:
lib/google/cloud/monitoring/v3/metric_service/paths.rb

#metric_descriptor_path(project: , metric_descriptor: ) ⇒ ::String #metric_descriptor_path(organization: , metric_descriptor: ) ⇒ ::String #metric_descriptor_path(folder: , metric_descriptor: ) ⇒ ::String

Create a fully-qualified MetricDescriptor resource string.

Overloads:

  • #metric_descriptor_path(project: , metric_descriptor: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/metricDescriptors/{metric_descriptor=**}

    Parameters:

    • project (String) (defaults to: )
    • metric_descriptor (String) (defaults to: )
  • #metric_descriptor_path(organization: , metric_descriptor: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/metricDescriptors/{metric_descriptor=**}

    Parameters:

    • organization (String) (defaults to: )
    • metric_descriptor (String) (defaults to: )
  • #metric_descriptor_path(folder: , metric_descriptor: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/metricDescriptors/{metric_descriptor=**}

    Parameters:

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

Returns:

  • (::String)

Raises:

  • (::ArgumentError)
[View source]

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/metric_service/paths.rb', line 69

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

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

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

      "folders/#{folder}/metricDescriptors/#{metric_descriptor}"
    end)
  }

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