# Copyright 2018 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
#
#     http://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.

"""This script is used to synthesize generated parts of this library."""

import synthtool as s
import synthtool.gcp as gcp

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
    service='pubsub',
    version='v1',
    config_path='/google/pubsub/artman_pubsub.yaml',
    artman_output_name='')

s.copy(library / 'gapic-google-cloud-pubsub-v1/src', 'src')
s.copy(library / 'grpc-google-cloud-pubsub-v1/src', '../../google-api-grpc/grpc-google-cloud-pubsub-v1/src')
s.copy(library / 'proto-google-cloud-pubsub-v1/src', '../../google-api-grpc/proto-google-cloud-pubsub-v1/src')

@@ -696,80 +696,197 @@
 gcp%0A
-%0Agapic = gcp.GAPICGenerator()%0Acommon_templates = gcp.CommonTemplates()%0A%0A
+import synthtool.languages.java as java%0A%0Agapic = gcp.GAPICGenerator()%0A%0Aservice = 'pubsub'%0Aversions = %5B'v1'%5D%0Aconfig_pattern = '/google/pubsub/artman_pubsub.yaml'%0A%0Afor version in versions:%0A  
 libr
@@ -911,16 +911,18 @@
 ibrary(%0A
+  
     serv
@@ -929,18 +929,19 @@
 ice=
-'pubsub',%0A
+service,%0A  
     
@@ -952,14 +952,19 @@
 ion=
-'v1',%0A
+version,%0A  
     
@@ -979,45 +979,50 @@
 ath=
-'/google/pubsub/artman_pubsub.yaml',%0A
+config_pattern.format(version=version),%0A  
     
@@ -1045,16 +1045,18 @@
 me='')%0A%0A
+  
 s.copy(l
@@ -1064,16 +1064,17 @@
 brary / 
+f
 'gapic-g
@@ -1081,33 +1081,43 @@
 oogle-cloud-
-pubsub-v1
+%7Bservice%7D-%7Bversion%7D
 /src', 'src'
@@ -1114,24 +1114,26 @@
 rc', 'src')%0A
+  
 s.copy(libra
@@ -1137,16 +1137,17 @@
 brary / 
+f
 'grpc-go
@@ -1157,32 +1157,43 @@
 e-cloud-
-pubsub-v1
+%7Bservice%7D-%7Bversion%7D
 /src', 
+f
 '../../g
@@ -1225,32 +1225,44 @@
 e-cloud-
-pubsub-v1
+%7Bservice%7D-%7Bversion%7D
 /src')%0A
+  
 s.copy(l
@@ -1270,16 +1270,17 @@
 brary / 
+f
 'proto-g
@@ -1295,24 +1295,35 @@
 oud-
-pubsub-v1
+%7Bservice%7D-%7Bversion%7D
 /src', 
+f
 '../
@@ -1364,17 +1364,231 @@
 oud-
-pubsub-v1
+%7Bservice%7D-%7Bversion%7D/src')%0A%0A  java.format_code('./src')%0A  java.format_code(f'../../google-api-grpc/grpc-google-cloud-%7Bservice%7D-%7Bversion%7D/src')%0A  java.format_code(f'../../google-api-grpc/proto-google-cloud-%7Bservice%7D-%7Bversion%7D
 /src

Add lint test and format generated code (#4114)