Module: Google::Cloud::BinaryAuthorization::V1::BinauthzManagementService::Paths

Extended by:
Paths
Included in:
Client, Paths
Defined in:
lib/google/cloud/binary_authorization/v1/binauthz_management_service/paths.rb

Overview

Path helper methods for the BinauthzManagementService API.

Instance Method Summary collapse

Instance Method Details

#attestor_path(project:, attestor:) ⇒ ::String

Create a fully-qualified Attestor resource string.

The resource will be in the following format:

projects/{project}/attestors/{attestor}

Parameters:

  • project (String)
  • attestor (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


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

def attestor_path project:, attestor:
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"

  "projects/#{project}/attestors/#{attestor}"
end

#policy_path(project: ) ⇒ ::String #policy_path(location: ) ⇒ ::String

Create a fully-qualified Policy resource string.

Overloads:

  • #policy_path(project: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/policy

    Parameters:

    • project (String) (defaults to: )
  • #policy_path(location: ) ⇒ ::String

    The resource will be in the following format:

    locations/{location}/policy

    Parameters:

    • location (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/google/cloud/binary_authorization/v1/binauthz_management_service/paths.rb', line 62

def policy_path **args
  resources = {
    "project" => (proc do |project:|
      "projects/#{project}/policy"
    end),
    "location" => (proc do |location:|
      "locations/#{location}/policy"
    end)
  }

  resource = resources[args.keys.sort.join(":")]
  raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
  resource.call(**args)
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)


87
88
89
# File 'lib/google/cloud/binary_authorization/v1/binauthz_management_service/paths.rb', line 87

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