Module: Google::Cloud::Asset::V1::AssetService::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/asset/v1/asset_service/paths.rb,
lib/google/cloud/asset/v1/asset_service/helpers.rb

Overview

Path helper methods for the AssetService API.

Instance Method Summary collapse

Instance Method Details

#feed_path(project: , feed: ) ⇒ ::String #feed_path(folder: , feed: ) ⇒ ::String #feed_path(organization: , feed: ) ⇒ ::String

Create a fully-qualified Feed resource string.

Overloads:

  • #feed_path(project: , feed: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/feeds/{feed}

    Parameters:

    • project (String) (defaults to: )
    • feed (String) (defaults to: )
  • #feed_path(folder: , feed: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/feeds/{feed}

    Parameters:

    • folder (String) (defaults to: )
    • feed (String) (defaults to: )
  • #feed_path(organization: , feed: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/feeds/{feed}

    Parameters:

    • organization (String) (defaults to: )
    • feed (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/asset/v1/asset_service/paths.rb', line 55

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

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

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

      "organizations/#{organization}/feeds/#{feed}"
    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)


89
90
91
# File 'lib/google/cloud/asset/v1/asset_service/paths.rb', line 89

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)


103
104
105
# File 'lib/google/cloud/asset/v1/asset_service/paths.rb', line 103

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)


117
118
119
# File 'lib/google/cloud/asset/v1/asset_service/paths.rb', line 117

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

#saved_query_path(project: , saved_query: ) ⇒ ::String #saved_query_path(folder: , saved_query: ) ⇒ ::String #saved_query_path(organization: , saved_query: ) ⇒ ::String

Create a fully-qualified SavedQuery resource string.

Overloads:

  • #saved_query_path(project: , saved_query: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/savedQueries/{saved_query}

    Parameters:

    • project (String) (defaults to: )
    • saved_query (String) (defaults to: )
  • #saved_query_path(folder: , saved_query: ) ⇒ ::String

    The resource will be in the following format:

    folders/{folder}/savedQueries/{saved_query}

    Parameters:

    • folder (String) (defaults to: )
    • saved_query (String) (defaults to: )
  • #saved_query_path(organization: , saved_query: ) ⇒ ::String

    The resource will be in the following format:

    organizations/{organization}/savedQueries/{saved_query}

    Parameters:

    • organization (String) (defaults to: )
    • saved_query (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/google/cloud/asset/v1/asset_service/paths.rb', line 149

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

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

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

      "organizations/#{organization}/savedQueries/#{saved_query}"
    end)
  }

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