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 synthtool as s 16from synthtool.languages import java 17 18get_grafeas_code = """ 19 /** 20 * Returns a new GrafeasClient with the same configured settings. 21 * 22 * @throws IOException 23 */ 24 public GrafeasClient getGrafeasClient() throws IOException { 25 return GrafeasClient.create(GrafeasUtils.transformSettings(settings)); 26 } 27""" 28 29for library in s.get_staging_dirs(): 30 # put any special-case replacements here 31 s.replace( 32 f'owl-bot-staging/v1/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java', 33 'import com.google.iam.v1.TestIamPermissionsResponse;', 34 'import com.google.iam.v1.TestIamPermissionsResponse;\nimport io.grafeas.v1.GrafeasClient;' 35 ) 36 37 # add getGrafeasClient() 38 s.replace( 39 f'owl-bot-staging/v1/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java', 40 r'(\s+private final ContainerAnalysisStub stub;.*)', 41 f'\g<1>{get_grafeas_code}' 42 ) 43 s.move(library) 44 45s.remove_staging_dirs() 46java.common_templates(monorepo=True, excludes=[ 47 ".github/*", 48 ".kokoro/*", 49 "samples/*", 50 "CODE_OF_CONDUCT.md", 51 "CONTRIBUTING.md", 52 "LICENSE", 53 "SECURITY.md", 54 "java.header", 55 "license-checks.xml", 56 "renovate.json", 57 ".gitignore" 58]) 59