lib/google/cloud/logging/v2/config_service/paths.rb in google-cloud-logging-v2-0.8.1 vs lib/google/cloud/logging/v2/config_service/paths.rb in google-cloud-logging-v2-0.9.0

- old
+ new

@@ -138,9 +138,90 @@ "folders/#{folder}/locations/#{location}" end ## + # Create a fully-qualified Link resource string. + # + # @overload link_path(project:, location:, bucket:, link:) + # The resource will be in the following format: + # + # `projects/{project}/locations/{location}/buckets/{bucket}/links/{link}` + # + # @param project [String] + # @param location [String] + # @param bucket [String] + # @param link [String] + # + # @overload link_path(organization:, location:, bucket:, link:) + # The resource will be in the following format: + # + # `organizations/{organization}/locations/{location}/buckets/{bucket}/links/{link}` + # + # @param organization [String] + # @param location [String] + # @param bucket [String] + # @param link [String] + # + # @overload link_path(folder:, location:, bucket:, link:) + # The resource will be in the following format: + # + # `folders/{folder}/locations/{location}/buckets/{bucket}/links/{link}` + # + # @param folder [String] + # @param location [String] + # @param bucket [String] + # @param link [String] + # + # @overload link_path(billing_account:, location:, bucket:, link:) + # The resource will be in the following format: + # + # `billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/links/{link}` + # + # @param billing_account [String] + # @param location [String] + # @param bucket [String] + # @param link [String] + # + # @return [::String] + def link_path **args + resources = { + "bucket:link:location:project" => (proc do |project:, location:, bucket:, link:| + raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/" + + "projects/#{project}/locations/#{location}/buckets/#{bucket}/links/#{link}" + end), + "bucket:link:location:organization" => (proc do |organization:, location:, bucket:, link:| + raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/" + + "organizations/#{organization}/locations/#{location}/buckets/#{bucket}/links/#{link}" + end), + "bucket:folder:link:location" => (proc do |folder:, location:, bucket:, link:| + raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/" + + "folders/#{folder}/locations/#{location}/buckets/#{bucket}/links/#{link}" + end), + "billing_account:bucket:link:location" => (proc do |billing_account:, location:, bucket:, link:| + raise ::ArgumentError, "billing_account cannot contain /" if billing_account.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/" + + "billingAccounts/#{billing_account}/locations/#{location}/buckets/#{bucket}/links/#{link}" + end) + } + + resource = resources[args.keys.sort.join(":")] + raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil? + resource.call(**args) + end + + ## # Create a fully-qualified Location resource string. # # The resource will be in the following format: # # `projects/{project}/locations/{location}`