Module: Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Paths

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

Overview

Path helper methods for the OrgPolicyViolationsPreviewService API.

Instance Method Summary collapse

Instance Method Details

#custom_constraint_path(organization:, custom_constraint:) ⇒ ::String

Create a fully-qualified CustomConstraint resource string.

The resource will be in the following format:

organizations/{organization}/customConstraints/{custom_constraint}

Parameters:

  • organization (String)
  • custom_constraint (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


38
39
40
41
42
# File 'lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/paths.rb', line 38

def custom_constraint_path organization:, custom_constraint:
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"

  "organizations/#{organization}/customConstraints/#{custom_constraint}"
end

#org_policy_violations_preview_path(organization:, location:, org_policy_violations_preview:) ⇒ ::String

Create a fully-qualified OrgPolicyViolationsPreview resource string.

The resource will be in the following format:

organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{org_policy_violations_preview}

Parameters:

  • organization (String)
  • location (String)
  • org_policy_violations_preview (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


56
57
58
59
60
61
# File 'lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/paths.rb', line 56

def org_policy_violations_preview_path organization:, location:, org_policy_violations_preview:
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"

  "organizations/#{organization}/locations/#{location}/orgPolicyViolationsPreviews/#{org_policy_violations_preview}"
end

#organization_location_path(organization:, location:) ⇒ ::String

Create a fully-qualified OrganizationLocation resource string.

The resource will be in the following format:

organizations/{organization}/locations/{location}

Parameters:

  • organization (String)
  • location (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


74
75
76
77
78
# File 'lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/paths.rb', line 74

def organization_location_path organization:, location:
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"

  "organizations/#{organization}/locations/#{location}"
end

#policy_path(project:, policy:) ⇒ ::String #policy_path(folder:, policy:) ⇒ ::String #policy_path(organization:, policy:) ⇒ ::String

Create a fully-qualified Policy resource string.

Overloads:

  • #policy_path(project:, policy:) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/policies/{policy}

    Parameters:

    • project (String)
    • policy (String)
  • #policy_path(folder:, policy:) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/policies/{policy}

    Parameters:

    • folder (String)
    • policy (String)
  • #policy_path(organization:, policy:) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/policies/{policy}

    Parameters:

    • organization (String)
    • policy (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/paths.rb', line 108

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

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

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

      "organizations/#{organization}/policies/#{policy}"
    end)
  }

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