diff --git a/google-cloud-support-v2/.owlbot-manifest.json b/google-cloud-support-v2/.owlbot-manifest.json index 36fad70fc033..9e8282fbcb41 100644 --- a/google-cloud-support-v2/.owlbot-manifest.json +++ b/google-cloud-support-v2/.owlbot-manifest.json @@ -56,6 +56,7 @@ "proto_docs/google/protobuf/field_mask.rb", "proto_docs/google/protobuf/timestamp.rb", "snippets/Gemfile", + "snippets/case_attachment_service/get_attachment.rb", "snippets/case_attachment_service/list_attachments.rb", "snippets/case_service/close_case.rb", "snippets/case_service/create_case.rb", @@ -66,6 +67,7 @@ "snippets/case_service/search_cases.rb", "snippets/case_service/update_case.rb", "snippets/comment_service/create_comment.rb", + "snippets/comment_service/get_comment.rb", "snippets/comment_service/list_comments.rb", "snippets/snippet_metadata_google.cloud.support.v2.json", "test/google/cloud/support/v2/case_attachment_service_paths_test.rb", diff --git a/google-cloud-support-v2/gapic_metadata.json b/google-cloud-support-v2/gapic_metadata.json index f357ef041882..6281b86846a7 100644 --- a/google-cloud-support-v2/gapic_metadata.json +++ b/google-cloud-support-v2/gapic_metadata.json @@ -14,6 +14,11 @@ "methods": [ "list_attachments" ] + }, + "GetAttachment": { + "methods": [ + "get_attachment" + ] } } } @@ -82,6 +87,11 @@ "methods": [ "create_comment" ] + }, + "GetComment": { + "methods": [ + "get_comment" + ] } } } diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_pb.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_pb.rb index 03ee8f0dc82d..c42b966e26ec 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_pb.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_pb.rb @@ -11,7 +11,7 @@ require 'google/cloud/support/v2/attachment_pb' -descriptor_data = "\n0google/cloud/support/v2/attachment_service.proto\x12\x17google.cloud.support.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/support/v2/attachment.proto\"y\n\x16ListAttachmentsRequest\x12\x38\n\x06parent\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n cloudsupport.googleapis.com/Case\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"l\n\x17ListAttachmentsResponse\x12\x38\n\x0b\x61ttachments\x18\x01 \x03(\x0b\x32#.google.cloud.support.v2.Attachment\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xd1\x02\n\x15\x43\x61seAttachmentService\x12\xe6\x01\n\x0fListAttachments\x12/.google.cloud.support.v2.ListAttachmentsRequest\x1a\x30.google.cloud.support.v2.ListAttachmentsResponse\"p\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x61\x12+/v2/{parent=projects/*/cases/*}/attachmentsZ2\x12\x30/v2/{parent=organizations/*/cases/*}/attachments\x1aO\xca\x41\x1b\x63loudsupport.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xbf\x01\n\x1b\x63om.google.cloud.support.v2B\x16\x41ttachmentServiceProtoP\x01Z5cloud.google.com/go/support/apiv2/supportpb;supportpb\xaa\x02\x17Google.Cloud.Support.V2\xca\x02\x17Google\\Cloud\\Support\\V2\xea\x02\x1aGoogle::Cloud::Support::V2b\x06proto3" +descriptor_data = "\n0google/cloud/support/v2/attachment_service.proto\x12\x17google.cloud.support.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/support/v2/attachment.proto\"y\n\x16ListAttachmentsRequest\x12\x38\n\x06parent\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n cloudsupport.googleapis.com/Case\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"T\n\x14GetAttachmentRequest\x12<\n\x04name\x18\x01 \x01(\tB.\xe0\x41\x02\xfa\x41(\n&cloudsupport.googleapis.com/Attachment\"l\n\x17ListAttachmentsResponse\x12\x38\n\x0b\x61ttachments\x18\x01 \x03(\x0b\x32#.google.cloud.support.v2.Attachment\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xec\x03\n\x15\x43\x61seAttachmentService\x12\xe6\x01\n\x0fListAttachments\x12/.google.cloud.support.v2.ListAttachmentsRequest\x1a\x30.google.cloud.support.v2.ListAttachmentsResponse\"p\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x61\x12+/v2/{parent=projects/*/cases/*}/attachmentsZ2\x12\x30/v2/{parent=organizations/*/cases/*}/attachments\x12\x98\x01\n\rGetAttachment\x12-.google.cloud.support.v2.GetAttachmentRequest\x1a#.google.cloud.support.v2.Attachment\"3\xda\x41\x04name\x82\xd3\xe4\x93\x02&\x12$/v2/{name=*/*/cases/*/attachments/*}\x1aO\xca\x41\x1b\x63loudsupport.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xbf\x01\n\x1b\x63om.google.cloud.support.v2B\x16\x41ttachmentServiceProtoP\x01Z5cloud.google.com/go/support/apiv2/supportpb;supportpb\xaa\x02\x17Google.Cloud.Support.V2\xca\x02\x17Google\\Cloud\\Support\\V2\xea\x02\x1aGoogle::Cloud::Support::V2b\x06proto3" pool = ::Google::Protobuf::DescriptorPool.generated_pool pool.add_serialized_file(descriptor_data) @@ -21,6 +21,7 @@ module Cloud module Support module V2 ListAttachmentsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.ListAttachmentsRequest").msgclass + GetAttachmentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.GetAttachmentRequest").msgclass ListAttachmentsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.ListAttachmentsResponse").msgclass end end diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_services_pb.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_services_pb.rb index 523fcd6b83d7..aa28222e9368 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_services_pb.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/attachment_service_services_pb.rb @@ -35,6 +35,38 @@ class Service # List all the attachments associated with a support case. rpc :ListAttachments, ::Google::Cloud::Support::V2::ListAttachmentsRequest, ::Google::Cloud::Support::V2::ListAttachmentsResponse + # Retrieve an attachment associated with a support case. + # + # EXAMPLES: + # + # cURL: + # + # ```shell + # attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB" + # curl \ + # --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + # "https://cloudsupport.googleapis.com/v2/$attachment" + # ``` + # + # Python: + # + # ```python + # import googleapiclient.discovery + # + # api_version = "v2" + # supportApiService = googleapiclient.discovery.build( + # serviceName="cloudsupport", + # version=api_version, + # discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", + # ) + # request = ( + # supportApiService.cases() + # .attachments() + # .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB") + # ) + # print(request.execute()) + # ``` + rpc :GetAttachment, ::Google::Cloud::Support::V2::GetAttachmentRequest, ::Google::Cloud::Support::V2::Attachment end Stub = Service.rpc_stub_class diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/client.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/client.rb index b8269c736cfc..469e8f630cef 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/client.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/client.rb @@ -291,6 +291,121 @@ def list_attachments request, options = nil raise ::Google::Cloud::Error.from_error(e) end + ## + # Retrieve an attachment associated with a support case. + # + # EXAMPLES: + # + # cURL: + # + # ```shell + # attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB" + # curl \ + # --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + # "https://cloudsupport.googleapis.com/v2/$attachment" + # ``` + # + # Python: + # + # ```python + # import googleapiclient.discovery + # + # api_version = "v2" + # supportApiService = googleapiclient.discovery.build( + # serviceName="cloudsupport", + # version=api_version, + # discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version=\\{api_version}", + # ) + # request = ( + # supportApiService.cases() + # .attachments() + # .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB") + # ) + # print(request.execute()) + # ``` + # + # @overload get_attachment(request, options = nil) + # Pass arguments to `get_attachment` via a request object, either of type + # {::Google::Cloud::Support::V2::GetAttachmentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::Support::V2::GetAttachmentRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_attachment(name: nil) + # Pass arguments to `get_attachment` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the attachment to get. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Cloud::Support::V2::Attachment] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Cloud::Support::V2::Attachment] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/support/v2" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::Support::V2::CaseAttachmentService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::Support::V2::GetAttachmentRequest.new + # + # # Call the get_attachment method. + # result = client.get_attachment request + # + # # The returned object is of type Google::Cloud::Support::V2::Attachment. + # p result + # + def get_attachment request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Support::V2::GetAttachmentRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_attachment.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Cloud::Support::V2::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_attachment.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_attachment.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @case_attachment_service_stub.call_rpc :get_attachment, request, options: options do |response, operation| + yield response, operation if block_given? + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + ## # Configuration class for the CaseAttachmentService API. # @@ -479,11 +594,18 @@ class Rpcs # @return [::Gapic::Config::Method] # attr_reader :list_attachments + ## + # RPC-specific configuration for `get_attachment` + # @return [::Gapic::Config::Method] + # + attr_reader :get_attachment # @private def initialize parent_rpcs = nil list_attachments_config = parent_rpcs.list_attachments if parent_rpcs.respond_to? :list_attachments @list_attachments = ::Gapic::Config::Method.new list_attachments_config + get_attachment_config = parent_rpcs.get_attachment if parent_rpcs.respond_to? :get_attachment + @get_attachment = ::Gapic::Config::Method.new get_attachment_config yield self if block_given? end diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/paths.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/paths.rb index 29440ea0d0fa..5f1287ae5584 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/paths.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/case_attachment_service/paths.rb @@ -24,6 +24,49 @@ module V2 module CaseAttachmentService # Path helper methods for the CaseAttachmentService API. module Paths + ## + # Create a fully-qualified Attachment resource string. + # + # @overload attachment_path(organization:, case:, attachment_id:) + # The resource will be in the following format: + # + # `organizations/{organization}/cases/{case}/attachments/{attachment_id}` + # + # @param organization [String] + # @param case [String] + # @param attachment_id [String] + # + # @overload attachment_path(project:, case:, attachment_id:) + # The resource will be in the following format: + # + # `projects/{project}/cases/{case}/attachments/{attachment_id}` + # + # @param project [String] + # @param case [String] + # @param attachment_id [String] + # + # @return [::String] + def attachment_path **args + resources = { + "attachment_id:case:organization" => (proc do |organization:, case:, attachment_id:| + raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/" + raise ::ArgumentError, "case cannot contain /" if binding.local_variable_get(:case).to_s.include? "/" + + "organizations/#{organization}/cases/#{binding.local_variable_get :case}/attachments/#{attachment_id}" + end), + "attachment_id:case:project" => (proc do |project:, case:, attachment_id:| + raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/" + raise ::ArgumentError, "case cannot contain /" if binding.local_variable_get(:case).to_s.include? "/" + + "projects/#{project}/cases/#{binding.local_variable_get :case}/attachments/#{attachment_id}" + 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 Case resource string. # diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service/client.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service/client.rb index f81ff7d38bc4..932e78073f3d 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service/client.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service/client.rb @@ -375,6 +375,120 @@ def create_comment request, options = nil raise ::Google::Cloud::Error.from_error(e) end + ## + # Retrieve a comment. + # + # EXAMPLES: + # + # cURL: + # + # ```shell + # comment="projects/some-project/cases/43595344/comments/234567890" + # curl \ + # --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + # "https://cloudsupport.googleapis.com/v2/$comment" + # ``` + # + # Python: + # + # ```python + # import googleapiclient.discovery + # + # api_version = "v2" + # supportApiService = googleapiclient.discovery.build( + # serviceName="cloudsupport", + # version=api_version, + # discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version=\\{api_version}", + # ) + # + # request = supportApiService.cases().comments().get( + # name="projects/some-project/cases/43595344/comments/234567890", + # ) + # print(request.execute()) + # ``` + # + # @overload get_comment(request, options = nil) + # Pass arguments to `get_comment` via a request object, either of type + # {::Google::Cloud::Support::V2::GetCommentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::Support::V2::GetCommentRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_comment(name: nil) + # Pass arguments to `get_comment` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the comment to retrieve. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Cloud::Support::V2::Comment] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Cloud::Support::V2::Comment] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/support/v2" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::Support::V2::CommentService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::Support::V2::GetCommentRequest.new + # + # # Call the get_comment method. + # result = client.get_comment request + # + # # The returned object is of type Google::Cloud::Support::V2::Comment. + # p result + # + def get_comment request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Support::V2::GetCommentRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_comment.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Cloud::Support::V2::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_comment.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_comment.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @comment_service_stub.call_rpc :get_comment, request, options: options do |response, operation| + yield response, operation if block_given? + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + ## # Configuration class for the CommentService API. # @@ -568,6 +682,11 @@ class Rpcs # @return [::Gapic::Config::Method] # attr_reader :create_comment + ## + # RPC-specific configuration for `get_comment` + # @return [::Gapic::Config::Method] + # + attr_reader :get_comment # @private def initialize parent_rpcs = nil @@ -575,6 +694,8 @@ def initialize parent_rpcs = nil @list_comments = ::Gapic::Config::Method.new list_comments_config create_comment_config = parent_rpcs.create_comment if parent_rpcs.respond_to? :create_comment @create_comment = ::Gapic::Config::Method.new create_comment_config + get_comment_config = parent_rpcs.get_comment if parent_rpcs.respond_to? :get_comment + @get_comment = ::Gapic::Config::Method.new get_comment_config yield self if block_given? end diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_pb.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_pb.rb index 771570302466..5d8d10ec5fad 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_pb.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_pb.rb @@ -11,7 +11,7 @@ require 'google/cloud/support/v2/comment_pb' -descriptor_data = "\n-google/cloud/support/v2/comment_service.proto\x12\x17google.cloud.support.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a%google/cloud/support/v2/comment.proto\"v\n\x13ListCommentsRequest\x12\x38\n\x06parent\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n cloudsupport.googleapis.com/Case\x12\x11\n\tpage_size\x18\x04 \x01(\x05\x12\x12\n\npage_token\x18\x05 \x01(\t\"c\n\x14ListCommentsResponse\x12\x32\n\x08\x63omments\x18\x01 \x03(\x0b\x32 .google.cloud.support.v2.Comment\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x88\x01\n\x14\x43reateCommentRequest\x12\x38\n\x06parent\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n cloudsupport.googleapis.com/Case\x12\x36\n\x07\x63omment\x18\x02 \x01(\x0b\x32 .google.cloud.support.v2.CommentB\x03\xe0\x41\x02\x32\xa5\x04\n\x0e\x43ommentService\x12\xd7\x01\n\x0cListComments\x12,.google.cloud.support.v2.ListCommentsRequest\x1a-.google.cloud.support.v2.ListCommentsResponse\"j\xda\x41\x06parent\x82\xd3\xe4\x93\x02[\x12(/v2/{parent=projects/*/cases/*}/commentsZ/\x12-/v2/{parent=organizations/*/cases/*}/comments\x12\xe7\x01\n\rCreateComment\x12-.google.cloud.support.v2.CreateCommentRequest\x1a .google.cloud.support.v2.Comment\"\x84\x01\xda\x41\x0eparent,comment\x82\xd3\xe4\x93\x02m\"(/v2/{parent=projects/*/cases/*}/comments:\x07\x63ommentZ8\"-/v2/{parent=organizations/*/cases/*}/comments:\x07\x63omment\x1aO\xca\x41\x1b\x63loudsupport.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xbc\x01\n\x1b\x63om.google.cloud.support.v2B\x13\x43ommentServiceProtoP\x01Z5cloud.google.com/go/support/apiv2/supportpb;supportpb\xaa\x02\x17Google.Cloud.Support.V2\xca\x02\x17Google\\Cloud\\Support\\V2\xea\x02\x1aGoogle::Cloud::Support::V2b\x06proto3" +descriptor_data = "\n-google/cloud/support/v2/comment_service.proto\x12\x17google.cloud.support.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a%google/cloud/support/v2/comment.proto\"v\n\x13ListCommentsRequest\x12\x38\n\x06parent\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n cloudsupport.googleapis.com/Case\x12\x11\n\tpage_size\x18\x04 \x01(\x05\x12\x12\n\npage_token\x18\x05 \x01(\t\"c\n\x14ListCommentsResponse\x12\x32\n\x08\x63omments\x18\x01 \x03(\x0b\x32 .google.cloud.support.v2.Comment\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x88\x01\n\x14\x43reateCommentRequest\x12\x38\n\x06parent\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n cloudsupport.googleapis.com/Case\x12\x36\n\x07\x63omment\x18\x02 \x01(\x0b\x32 .google.cloud.support.v2.CommentB\x03\xe0\x41\x02\"N\n\x11GetCommentRequest\x12\x39\n\x04name\x18\x01 \x01(\tB+\xe0\x41\x02\xfa\x41%\n#cloudsupport.googleapis.com/Comment2\xb4\x05\n\x0e\x43ommentService\x12\xd7\x01\n\x0cListComments\x12,.google.cloud.support.v2.ListCommentsRequest\x1a-.google.cloud.support.v2.ListCommentsResponse\"j\xda\x41\x06parent\x82\xd3\xe4\x93\x02[\x12(/v2/{parent=projects/*/cases/*}/commentsZ/\x12-/v2/{parent=organizations/*/cases/*}/comments\x12\xe7\x01\n\rCreateComment\x12-.google.cloud.support.v2.CreateCommentRequest\x1a .google.cloud.support.v2.Comment\"\x84\x01\xda\x41\x0eparent,comment\x82\xd3\xe4\x93\x02m\"(/v2/{parent=projects/*/cases/*}/comments:\x07\x63ommentZ8\"-/v2/{parent=organizations/*/cases/*}/comments:\x07\x63omment\x12\x8c\x01\n\nGetComment\x12*.google.cloud.support.v2.GetCommentRequest\x1a .google.cloud.support.v2.Comment\"0\xda\x41\x04name\x82\xd3\xe4\x93\x02#\x12!/v2/{name=*/*/cases/*/comments/*}\x1aO\xca\x41\x1b\x63loudsupport.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xbc\x01\n\x1b\x63om.google.cloud.support.v2B\x13\x43ommentServiceProtoP\x01Z5cloud.google.com/go/support/apiv2/supportpb;supportpb\xaa\x02\x17Google.Cloud.Support.V2\xca\x02\x17Google\\Cloud\\Support\\V2\xea\x02\x1aGoogle::Cloud::Support::V2b\x06proto3" pool = ::Google::Protobuf::DescriptorPool.generated_pool pool.add_serialized_file(descriptor_data) @@ -23,6 +23,7 @@ module V2 ListCommentsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.ListCommentsRequest").msgclass ListCommentsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.ListCommentsResponse").msgclass CreateCommentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.CreateCommentRequest").msgclass + GetCommentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.support.v2.GetCommentRequest").msgclass end end end diff --git a/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_services_pb.rb b/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_services_pb.rb index 667513cb3cce..26e2beb75037 100644 --- a/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_services_pb.rb +++ b/google-cloud-support-v2/lib/google/cloud/support/v2/comment_service_services_pb.rb @@ -39,6 +39,37 @@ class Service # # The comment must have the following fields set: `body`. rpc :CreateComment, ::Google::Cloud::Support::V2::CreateCommentRequest, ::Google::Cloud::Support::V2::Comment + # Retrieve a comment. + # + # EXAMPLES: + # + # cURL: + # + # ```shell + # comment="projects/some-project/cases/43595344/comments/234567890" + # curl \ + # --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + # "https://cloudsupport.googleapis.com/v2/$comment" + # ``` + # + # Python: + # + # ```python + # import googleapiclient.discovery + # + # api_version = "v2" + # supportApiService = googleapiclient.discovery.build( + # serviceName="cloudsupport", + # version=api_version, + # discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", + # ) + # + # request = supportApiService.cases().comments().get( + # name="projects/some-project/cases/43595344/comments/234567890", + # ) + # print(request.execute()) + # ``` + rpc :GetComment, ::Google::Cloud::Support::V2::GetCommentRequest, ::Google::Cloud::Support::V2::Comment end Stub = Service.rpc_stub_class diff --git a/google-cloud-support-v2/proto_docs/google/cloud/support/v2/attachment_service.rb b/google-cloud-support-v2/proto_docs/google/cloud/support/v2/attachment_service.rb index cda8d689574a..d50bf358e5cf 100644 --- a/google-cloud-support-v2/proto_docs/google/cloud/support/v2/attachment_service.rb +++ b/google-cloud-support-v2/proto_docs/google/cloud/support/v2/attachment_service.rb @@ -44,6 +44,15 @@ class ListAttachmentsRequest extend ::Google::Protobuf::MessageExts::ClassMethods end + # Request for getting an attachment. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the attachment to get. + class GetAttachmentRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + # The response message for the ListAttachments endpoint. # @!attribute [rw] attachments # @return [::Array<::Google::Cloud::Support::V2::Attachment>] diff --git a/google-cloud-support-v2/proto_docs/google/cloud/support/v2/comment_service.rb b/google-cloud-support-v2/proto_docs/google/cloud/support/v2/comment_service.rb index 78e919af7569..9be5de21e792 100644 --- a/google-cloud-support-v2/proto_docs/google/cloud/support/v2/comment_service.rb +++ b/google-cloud-support-v2/proto_docs/google/cloud/support/v2/comment_service.rb @@ -62,6 +62,15 @@ class CreateCommentRequest include ::Google::Protobuf::MessageExts extend ::Google::Protobuf::MessageExts::ClassMethods end + + # The request message for the GetComment endpoint. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the comment to retrieve. + class GetCommentRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end end end end diff --git a/google-cloud-support-v2/snippets/case_attachment_service/get_attachment.rb b/google-cloud-support-v2/snippets/case_attachment_service/get_attachment.rb new file mode 100644 index 000000000000..594fc4b9038f --- /dev/null +++ b/google-cloud-support-v2/snippets/case_attachment_service/get_attachment.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_sync] +require "google/cloud/support/v2" + +## +# Snippet for the get_attachment call in the CaseAttachmentService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Cloud::Support::V2::CaseAttachmentService::Client#get_attachment. +# +def get_attachment + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::Support::V2::CaseAttachmentService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::Support::V2::GetAttachmentRequest.new + + # Call the get_attachment method. + result = client.get_attachment request + + # The returned object is of type Google::Cloud::Support::V2::Attachment. + p result +end +# [END cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_sync] diff --git a/google-cloud-support-v2/snippets/comment_service/get_comment.rb b/google-cloud-support-v2/snippets/comment_service/get_comment.rb new file mode 100644 index 000000000000..78850b5b4cba --- /dev/null +++ b/google-cloud-support-v2/snippets/comment_service/get_comment.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START cloudsupport_v2_generated_CommentService_GetComment_sync] +require "google/cloud/support/v2" + +## +# Snippet for the get_comment call in the CommentService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Cloud::Support::V2::CommentService::Client#get_comment. +# +def get_comment + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::Support::V2::CommentService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::Support::V2::GetCommentRequest.new + + # Call the get_comment method. + result = client.get_comment request + + # The returned object is of type Google::Cloud::Support::V2::Comment. + p result +end +# [END cloudsupport_v2_generated_CommentService_GetComment_sync] diff --git a/google-cloud-support-v2/snippets/snippet_metadata_google.cloud.support.v2.json b/google-cloud-support-v2/snippets/snippet_metadata_google.cloud.support.v2.json index 0905c4b02a52..9b3dd031dce7 100644 --- a/google-cloud-support-v2/snippets/snippet_metadata_google.cloud.support.v2.json +++ b/google-cloud-support-v2/snippets/snippet_metadata_google.cloud.support.v2.json @@ -51,6 +51,46 @@ } ] }, + { + "region_tag": "cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_sync", + "title": "Snippet for the get_attachment call in the CaseAttachmentService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::Support::V2::CaseAttachmentService::Client#get_attachment.", + "file": "case_attachment_service/get_attachment.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_attachment", + "full_name": "::Google::Cloud::Support::V2::CaseAttachmentService::Client#get_attachment", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::Support::V2::GetAttachmentRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::Support::V2::Attachment", + "client": { + "short_name": "CaseAttachmentService::Client", + "full_name": "::Google::Cloud::Support::V2::CaseAttachmentService::Client" + }, + "method": { + "short_name": "GetAttachment", + "full_name": "google.cloud.support.v2.CaseAttachmentService.GetAttachment", + "service": { + "short_name": "CaseAttachmentService", + "full_name": "google.cloud.support.v2.CaseAttachmentService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, { "region_tag": "cloudsupport_v2_generated_CaseService_GetCase_sync", "title": "Snippet for the get_case call in the CaseService service", @@ -450,6 +490,46 @@ "type": "FULL" } ] + }, + { + "region_tag": "cloudsupport_v2_generated_CommentService_GetComment_sync", + "title": "Snippet for the get_comment call in the CommentService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::Support::V2::CommentService::Client#get_comment.", + "file": "comment_service/get_comment.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_comment", + "full_name": "::Google::Cloud::Support::V2::CommentService::Client#get_comment", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::Support::V2::GetCommentRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::Support::V2::Comment", + "client": { + "short_name": "CommentService::Client", + "full_name": "::Google::Cloud::Support::V2::CommentService::Client" + }, + "method": { + "short_name": "GetComment", + "full_name": "google.cloud.support.v2.CommentService.GetComment", + "service": { + "short_name": "CommentService", + "full_name": "google.cloud.support.v2.CommentService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] } ] } \ No newline at end of file diff --git a/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_paths_test.rb b/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_paths_test.rb index c7cf335b120f..ad49f0cbbe7e 100644 --- a/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_paths_test.rb +++ b/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_paths_test.rb @@ -41,6 +41,21 @@ def logger end end + def test_attachment_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Cloud::Support::V2::CaseAttachmentService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.attachment_path organization: "value0", case: "value1", attachment_id: "value2" + assert_equal "organizations/value0/cases/value1/attachments/value2", path + + path = client.attachment_path project: "value0", case: "value1", attachment_id: "value2" + assert_equal "projects/value0/cases/value1/attachments/value2", path + end + end + def test_case_path grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure ::Gapic::ServiceStub.stub :new, DummyStub.new do diff --git a/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_test.rb b/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_test.rb index c1efa7e69ee6..eb68ed0469b5 100644 --- a/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_test.rb +++ b/google-cloud-support-v2/test/google/cloud/support/v2/case_attachment_service_test.rb @@ -130,6 +130,64 @@ def test_list_attachments end end + def test_get_attachment + # Create GRPC objects. + grpc_response = ::Google::Cloud::Support::V2::Attachment.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_attachment_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_attachment, name + assert_kind_of ::Google::Cloud::Support::V2::GetAttachmentRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_attachment_client_stub do + # Create client + client = ::Google::Cloud::Support::V2::CaseAttachmentService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_attachment({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_attachment name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_attachment ::Google::Cloud::Support::V2::GetAttachmentRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_attachment({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_attachment(::Google::Cloud::Support::V2::GetAttachmentRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_attachment_client_stub.call_rpc_count + end + end + def test_configure grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure diff --git a/google-cloud-support-v2/test/google/cloud/support/v2/comment_service_test.rb b/google-cloud-support-v2/test/google/cloud/support/v2/comment_service_test.rb index 74d666fdf444..832b1a33642d 100644 --- a/google-cloud-support-v2/test/google/cloud/support/v2/comment_service_test.rb +++ b/google-cloud-support-v2/test/google/cloud/support/v2/comment_service_test.rb @@ -190,6 +190,64 @@ def test_create_comment end end + def test_get_comment + # Create GRPC objects. + grpc_response = ::Google::Cloud::Support::V2::Comment.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_comment_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_comment, name + assert_kind_of ::Google::Cloud::Support::V2::GetCommentRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_comment_client_stub do + # Create client + client = ::Google::Cloud::Support::V2::CommentService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_comment({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_comment name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_comment ::Google::Cloud::Support::V2::GetCommentRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_comment({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_comment(::Google::Cloud::Support::V2::GetCommentRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_comment_client_stub.call_rpc_count + end + end + def test_configure grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure