Skip to content

Commit fd4a9d5

Browse files
feat: v2 version for GetComment and GetAttachment (#33946)
* feat: v2 version for `GetComment` and `GetAttachment` PiperOrigin-RevId: 915218100 Source-Link: googleapis/googleapis@3aa565f Source-Link: googleapis/googleapis-gen@049fe6a Copy-Tag: eyJwIjoiZ29vZ2xlLWNsb3VkLXN1cHBvcnQtdjIvLk93bEJvdC55YW1sIiwiaCI6IjA0OWZlNmE5NjljN2E1NWYyOTMzMjhhYWYxNmQyNzM1ZjlhMjI0NzEifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 24e62c7 commit fd4a9d5

17 files changed

Lines changed: 688 additions & 2 deletions

File tree

google-cloud-support-v2/.owlbot-manifest.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"proto_docs/google/protobuf/field_mask.rb",
5757
"proto_docs/google/protobuf/timestamp.rb",
5858
"snippets/Gemfile",
59+
"snippets/case_attachment_service/get_attachment.rb",
5960
"snippets/case_attachment_service/list_attachments.rb",
6061
"snippets/case_service/close_case.rb",
6162
"snippets/case_service/create_case.rb",
@@ -66,6 +67,7 @@
6667
"snippets/case_service/search_cases.rb",
6768
"snippets/case_service/update_case.rb",
6869
"snippets/comment_service/create_comment.rb",
70+
"snippets/comment_service/get_comment.rb",
6971
"snippets/comment_service/list_comments.rb",
7072
"snippets/snippet_metadata_google.cloud.support.v2.json",
7173
"test/google/cloud/support/v2/case_attachment_service_paths_test.rb",

google-cloud-support-v2/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"methods": [
1515
"list_attachments"
1616
]
17+
},
18+
"GetAttachment": {
19+
"methods": [
20+
"get_attachment"
21+
]
1722
}
1823
}
1924
}
@@ -82,6 +87,11 @@
8287
"methods": [
8388
"create_comment"
8489
]
90+
},
91+
"GetComment": {
92+
"methods": [
93+
"get_comment"
94+
]
8595
}
8696
}
8797
}

google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_pb.rb

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_services_pb.rb

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/client.rb

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,121 @@ def list_attachments request, options = nil
291291
raise ::Google::Cloud::Error.from_error(e)
292292
end
293293

294+
##
295+
# Retrieve an attachment associated with a support case.
296+
#
297+
# EXAMPLES:
298+
#
299+
# cURL:
300+
#
301+
# ```shell
302+
# attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB"
303+
# curl \
304+
# --header "Authorization: Bearer $(gcloud auth print-access-token)" \
305+
# "https://cloudsupport.googleapis.com/v2/$attachment"
306+
# ```
307+
#
308+
# Python:
309+
#
310+
# ```python
311+
# import googleapiclient.discovery
312+
#
313+
# api_version = "v2"
314+
# supportApiService = googleapiclient.discovery.build(
315+
# serviceName="cloudsupport",
316+
# version=api_version,
317+
# discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version=\\{api_version}",
318+
# )
319+
# request = (
320+
# supportApiService.cases()
321+
# .attachments()
322+
# .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB")
323+
# )
324+
# print(request.execute())
325+
# ```
326+
#
327+
# @overload get_attachment(request, options = nil)
328+
# Pass arguments to `get_attachment` via a request object, either of type
329+
# {::Google::Cloud::Support::V2::GetAttachmentRequest} or an equivalent Hash.
330+
#
331+
# @param request [::Google::Cloud::Support::V2::GetAttachmentRequest, ::Hash]
332+
# A request object representing the call parameters. Required. To specify no
333+
# parameters, or to keep all the default parameter values, pass an empty Hash.
334+
# @param options [::Gapic::CallOptions, ::Hash]
335+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
336+
#
337+
# @overload get_attachment(name: nil)
338+
# Pass arguments to `get_attachment` via keyword arguments. Note that at
339+
# least one keyword argument is required. To specify no parameters, or to keep all
340+
# the default parameter values, pass an empty Hash as a request object (see above).
341+
#
342+
# @param name [::String]
343+
# Required. The name of the attachment to get.
344+
#
345+
# @yield [response, operation] Access the result along with the RPC operation
346+
# @yieldparam response [::Google::Cloud::Support::V2::Attachment]
347+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
348+
#
349+
# @return [::Google::Cloud::Support::V2::Attachment]
350+
#
351+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
352+
#
353+
# @example Basic example
354+
# require "google/cloud/support/v2"
355+
#
356+
# # Create a client object. The client can be reused for multiple calls.
357+
# client = Google::Cloud::Support::V2::CaseAttachmentService::Client.new
358+
#
359+
# # Create a request. To set request fields, pass in keyword arguments.
360+
# request = Google::Cloud::Support::V2::GetAttachmentRequest.new
361+
#
362+
# # Call the get_attachment method.
363+
# result = client.get_attachment request
364+
#
365+
# # The returned object is of type Google::Cloud::Support::V2::Attachment.
366+
# p result
367+
#
368+
def get_attachment request, options = nil
369+
raise ::ArgumentError, "request must be provided" if request.nil?
370+
371+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Support::V2::GetAttachmentRequest
372+
373+
# Converts hash and nil to an options object
374+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
375+
376+
# Customize the options with defaults
377+
metadata = @config.rpcs.get_attachment.metadata.to_h
378+
379+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
380+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
381+
lib_name: @config.lib_name, lib_version: @config.lib_version,
382+
gapic_version: ::Google::Cloud::Support::V2::VERSION
383+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
384+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
385+
386+
header_params = {}
387+
if request.name
388+
header_params["name"] = request.name
389+
end
390+
391+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
392+
metadata[:"x-goog-request-params"] ||= request_params_header
393+
394+
options.apply_defaults timeout: @config.rpcs.get_attachment.timeout,
395+
metadata: metadata,
396+
retry_policy: @config.rpcs.get_attachment.retry_policy
397+
398+
options.apply_defaults timeout: @config.timeout,
399+
metadata: @config.metadata,
400+
retry_policy: @config.retry_policy
401+
402+
@case_attachment_service_stub.call_rpc :get_attachment, request, options: options do |response, operation|
403+
yield response, operation if block_given?
404+
end
405+
rescue ::GRPC::BadStatus => e
406+
raise ::Google::Cloud::Error.from_error(e)
407+
end
408+
294409
##
295410
# Configuration class for the CaseAttachmentService API.
296411
#
@@ -479,11 +594,18 @@ class Rpcs
479594
# @return [::Gapic::Config::Method]
480595
#
481596
attr_reader :list_attachments
597+
##
598+
# RPC-specific configuration for `get_attachment`
599+
# @return [::Gapic::Config::Method]
600+
#
601+
attr_reader :get_attachment
482602

483603
# @private
484604
def initialize parent_rpcs = nil
485605
list_attachments_config = parent_rpcs.list_attachments if parent_rpcs.respond_to? :list_attachments
486606
@list_attachments = ::Gapic::Config::Method.new list_attachments_config
607+
get_attachment_config = parent_rpcs.get_attachment if parent_rpcs.respond_to? :get_attachment
608+
@get_attachment = ::Gapic::Config::Method.new get_attachment_config
487609

488610
yield self if block_given?
489611
end

google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/paths.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,49 @@ module V2
2424
module CaseAttachmentService
2525
# Path helper methods for the CaseAttachmentService API.
2626
module Paths
27+
##
28+
# Create a fully-qualified Attachment resource string.
29+
#
30+
# @overload attachment_path(organization:, case:, attachment_id:)
31+
# The resource will be in the following format:
32+
#
33+
# `organizations/{organization}/cases/{case}/attachments/{attachment_id}`
34+
#
35+
# @param organization [String]
36+
# @param case [String]
37+
# @param attachment_id [String]
38+
#
39+
# @overload attachment_path(project:, case:, attachment_id:)
40+
# The resource will be in the following format:
41+
#
42+
# `projects/{project}/cases/{case}/attachments/{attachment_id}`
43+
#
44+
# @param project [String]
45+
# @param case [String]
46+
# @param attachment_id [String]
47+
#
48+
# @return [::String]
49+
def attachment_path **args
50+
resources = {
51+
"attachment_id:case:organization" => (proc do |organization:, case:, attachment_id:|
52+
raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
53+
raise ::ArgumentError, "case cannot contain /" if binding.local_variable_get(:case).to_s.include? "/"
54+
55+
"organizations/#{organization}/cases/#{binding.local_variable_get :case}/attachments/#{attachment_id}"
56+
end),
57+
"attachment_id:case:project" => (proc do |project:, case:, attachment_id:|
58+
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
59+
raise ::ArgumentError, "case cannot contain /" if binding.local_variable_get(:case).to_s.include? "/"
60+
61+
"projects/#{project}/cases/#{binding.local_variable_get :case}/attachments/#{attachment_id}"
62+
end)
63+
}
64+
65+
resource = resources[args.keys.sort.join(":")]
66+
raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
67+
resource.call(**args)
68+
end
69+
2770
##
2871
# Create a fully-qualified Case resource string.
2972
#

0 commit comments

Comments
 (0)