Module: Google::Cloud::Monitoring::V3::AlertPolicyService::Paths

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

Overview

Path helper methods for the AlertPolicyService API.

Instance Method Summary collapse

Instance Method Details

#alert_policy_condition_path(project: , alert_policy: , condition: ) ⇒ ::String #alert_policy_condition_path(organization: , alert_policy: , condition: ) ⇒ ::String #alert_policy_condition_path(folder: , alert_policy: , condition: ) ⇒ ::String

Create a fully-qualified AlertPolicyCondition resource string.

Overloads:

  • #alert_policy_condition_path(project: , alert_policy: , condition: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}

    Parameters:

    • project (String) (defaults to: )
    • alert_policy (String) (defaults to: )
    • condition (String) (defaults to: )
  • #alert_policy_condition_path(organization: , alert_policy: , condition: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}

    Parameters:

    • organization (String) (defaults to: )
    • alert_policy (String) (defaults to: )
    • condition (String) (defaults to: )
  • #alert_policy_condition_path(folder: , alert_policy: , condition: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}

    Parameters:

    • folder (String) (defaults to: )
    • alert_policy (String) (defaults to: )
    • condition (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/google/cloud/monitoring/v3/alert_policy_service/paths.rb', line 110

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

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

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

      "folders/#{folder}/alertPolicies/#{alert_policy}/conditions/#{condition}"
    end)
  }

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

#alert_policy_path(project: , alert_policy: ) ⇒ ::String #alert_policy_path(organization: , alert_policy: ) ⇒ ::String #alert_policy_path(folder: , alert_policy: ) ⇒ ::String

Create a fully-qualified AlertPolicy resource string.

Overloads:

  • #alert_policy_path(project: , alert_policy: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/alertPolicies/{alert_policy}

    Parameters:

    • project (String) (defaults to: )
    • alert_policy (String) (defaults to: )
  • #alert_policy_path(organization: , alert_policy: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/alertPolicies/{alert_policy}

    Parameters:

    • organization (String) (defaults to: )
    • alert_policy (String) (defaults to: )
  • #alert_policy_path(folder: , alert_policy: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/alertPolicies/{alert_policy}

    Parameters:

    • folder (String) (defaults to: )
    • alert_policy (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/monitoring/v3/alert_policy_service/paths.rb', line 55

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

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

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

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


147
148
149
# File 'lib/google/cloud/monitoring/v3/alert_policy_service/paths.rb', line 147

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)


161
162
163
# File 'lib/google/cloud/monitoring/v3/alert_policy_service/paths.rb', line 161

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)


175
176
177
# File 'lib/google/cloud/monitoring/v3/alert_policy_service/paths.rb', line 175

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)


197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/google/cloud/monitoring/v3/alert_policy_service/paths.rb', line 197

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