Module: Google::Cloud::SecretManager::V1beta2::SecretManagerService::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/secret_manager/v1beta2/secret_manager_service/paths.rb

Overview

Path helper methods for the SecretManagerService API.

Instance Method Summary collapse

Instance Method Details

#location_path(project:, location:) ⇒ ::String

Create a fully-qualified Location resource string.

The resource will be in the following format:

projects/{project}/locations/{location}

Parameters:

  • project (String)
  • location (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


38
39
40
41
42
# File 'lib/google/cloud/secret_manager/v1beta2/secret_manager_service/paths.rb', line 38

def location_path project:, location:
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"

  "projects/#{project}/locations/#{location}"
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)


54
55
56
# File 'lib/google/cloud/secret_manager/v1beta2/secret_manager_service/paths.rb', line 54

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

#secret_path(project: , secret: ) ⇒ ::String #secret_path(project: , location: , secret: ) ⇒ ::String

Create a fully-qualified Secret resource string.

Overloads:

  • #secret_path(project: , secret: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/secrets/{secret}

    Parameters:

    • project (String) (defaults to: )
    • secret (String) (defaults to: )
  • #secret_path(project: , location: , secret: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/secrets/{secret}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • secret (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/google/cloud/secret_manager/v1beta2/secret_manager_service/paths.rb', line 79

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

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

      "projects/#{project}/locations/#{location}/secrets/#{secret}"
    end)
  }

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

#secret_version_path(project: , secret: , secret_version: ) ⇒ ::String #secret_version_path(project: , location: , secret: , secret_version: ) ⇒ ::String

Create a fully-qualified SecretVersion resource string.

Overloads:

  • #secret_version_path(project: , secret: , secret_version: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/secrets/{secret}/versions/{secret_version}

    Parameters:

    • project (String) (defaults to: )
    • secret (String) (defaults to: )
    • secret_version (String) (defaults to: )
  • #secret_version_path(project: , location: , secret: , secret_version: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/secrets/{secret}/versions/{secret_version}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • secret (String) (defaults to: )
    • secret_version (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/google/cloud/secret_manager/v1beta2/secret_manager_service/paths.rb', line 122

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

      "projects/#{project}/secrets/#{secret}/versions/#{secret_version}"
    end),
    "location:project:secret:secret_version" => (proc do |project:, location:, secret:, secret_version:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
      raise ::ArgumentError, "secret cannot contain /" if secret.to_s.include? "/"

      "projects/#{project}/locations/#{location}/secrets/#{secret}/versions/#{secret_version}"
    end)
  }

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

#topic_path(project:, topic:) ⇒ ::String

Create a fully-qualified Topic resource string.

The resource will be in the following format:

projects/{project}/topics/{topic}

Parameters:

  • project (String)
  • topic (String)

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


155
156
157
158
159
# File 'lib/google/cloud/secret_manager/v1beta2/secret_manager_service/paths.rb', line 155

def topic_path project:, topic:
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"

  "projects/#{project}/topics/#{topic}"
end