1# Copyright 2021 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import os 16import synthtool as s 17from synthtool.languages import java 18 19 20for library in s.get_staging_dirs(): 21 # put any special-case replacements here 22 ERROR_GROUP_OVERLOAD = """ 23 // Inserted by synthtool to preserve backwards-compatibility 24 /** 25 * Get the specified group. 26 * 27 * <p>Sample code: 28 * 29 * <pre><code> 30 * try (ErrorGroupServiceClient errorGroupServiceClient = ErrorGroupServiceClient.create()) { 31 * GroupName groupName = GroupName.of("[PROJECT]", "[GROUP]"); 32 * ErrorGroup response = errorGroupServiceClient.getGroup(groupName); 33 * } 34 * </code></pre> 35 * 36 * @param groupName Required. The group resource name. Written as 37 * <code>projects/<var>projectID</var>/groups/<var>group_name</var></code>. 38 * Call <a href="/error-reporting/reference/rest/v1beta1/projects.groupStats/list"> 39 * <code>groupStats.list</code></a> to return a list of groups belonging to 40 * this project. 41 * <p>Example: <code>projects/my-project-123/groups/my-group</code> 42 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 43 * @deprecated Use ErrorGroupServiceClient#getGroup(ErrorGroupName) 44 */ 45 @Deprecated 46 public final ErrorGroup getGroup(GroupName groupName) { 47 48 GetGroupRequest request = 49 GetGroupRequest.newBuilder() 50 .setGroupName(groupName == null ? null : groupName.toString()) 51 .build(); 52 return getGroup(request); 53 } 54 """ 55 56 ERROR_GROUP_OVERLOAD_PREVIOUS_METHOD = r'(\s+public ErrorGroupServiceStub getStub\(\) {\n\s+return stub;\n\s+})' 57 58 version = library.parts[len(library.parts) - 1] 59 service = 'errorreporting' 60 61 #java.fix_proto_headers('owl-bot-staging/v2beta1/proto-google-cloud-error-reporting-v1beta1') 62 #java.fix_grpc_headers('owl-bot-staging/v2beta1/grpc-google-cloud-error-reporting-v1beta1', "") 63 64 s.replace( 65 'owl-bot-staging/v1beta1/google-cloud-errorreporting/src/**/ErrorGroupServiceClient.java', 66 ERROR_GROUP_OVERLOAD_PREVIOUS_METHOD, 67 "\g<1>\n\n" + ERROR_GROUP_OVERLOAD 68 ) 69 s.replace( 70 'owl-bot-staging/v1beta1/google-cloud-errorreporting/src/**/ErrorGroupServiceClient.java', 71 "import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupName;", 72 "import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupName;\nimport com.google.devtools.clouderrorreporting.v1beta1.GroupName;" 73 ) 74 75 s.move(library) 76 77s.remove_staging_dirs() 78java.common_templates(monorepo=True, excludes=[ 79 ".github/*", 80 ".kokoro/*", 81 "samples/*", 82 "CODE_OF_CONDUCT.md", 83 "CONTRIBUTING.md", 84 "LICENSE", 85 "SECURITY.md", 86 "java.header", 87 "license-checks.xml", 88 "renovate.json", 89 ".gitignore" 90]) 91