def test_remove_method(): with tempfile.TemporaryDirectory() as tempdir: shutil.copyfile("tests/testdata/SampleClass.java", tempdir + "/SampleClass.java") java.remove_method(tempdir + "/SampleClass.java", "public static void foo()") java.remove_method(tempdir + "/SampleClass.java", "public void asdf()") assert_matches_golden("tests/testdata/SampleClassGolden.java", tempdir + "/SampleClass.java")
# 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. import synthtool as s from synthtool.languages import java for library in s.get_staging_dirs(): # put any special-case replacements here # Ensure backwards-compat for Java-microgenerator migration # Details: https://github.com/googleapis/synthtool/pull/883 java.remove_method( 'owl-bot-staging/v1/proto-google-cloud-bigquerydatatransfer-v1/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataSourceName.java', 'public static List<DataSourceName> parseList(List<String> formattedStrings)' ) java.remove_method( 'owl-bot-staging/v1/proto-google-cloud-bigquerydatatransfer-v1/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataSourceName.java', 'public static List<String> toStringList(List<DataSourceName> values)') java.remove_method( 'owl-bot-staging/v1/proto-google-cloud-bigquerydatatransfer-v1/src/main/java/com/google/cloud/bigquery/datatransfer/v1/TransferConfigName.java', 'public static List<TransferConfigName> parseList(List<String> formattedStrings)' ) java.remove_method( 'owl-bot-staging/v1/proto-google-cloud-bigquerydatatransfer-v1/src/main/java/com/google/cloud/bigquery/datatransfer/v1/TransferConfigName.java', 'public static List<String> toStringList(List<TransferConfigName> values)' ) java.remove_method( 'owl-bot-staging/v1/proto-google-cloud-bigquerydatatransfer-v1/src/main/java/com/google/cloud/bigquery/datatransfer/v1/RunName.java', 'public static List<RunName> parseList(List<String> formattedStrings)')
s.replace( sources, before=r'/\*\*.+?\*/\n(?:^@[^\n]*\n)*(?=public [a-zA-B ]*class)', after= '/** For internal use only. */\n@Generated("by gapic-generator")\n@InternalApi\n', flags=re.MULTILINE | re.DOTALL) for library in s.get_staging_dirs(): # put any special-case replacements here make_internal_only(data_internal_only) # Generate admin client #todo: fix in synthtool removing comments with method java.remove_method( f'owl-bot-staging/v2/grpc-google-cloud-bigtable-admin-v2/src/main/java/com/google/bigtable/admin/v2/BigtableInstanceAdminGrpc.java', "public UnaryCallSettings<Instance, Instance> updateInstanceSettings()" ) java.remove_method( f'owl-bot-staging/v2/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "/** Returns the builder for the settings used for calls to updateInstance. */" ) java.remove_method( f'owl-bot-staging/v2/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "public UnaryCallSettings.Builder<Instance, Instance> updateInstanceSettings()" ) java.remove_method( f'owl-bot-staging/v2/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "/** Returns the object with the settings used for calls to updateInstance. */" ) java.remove_method( f'owl-bot-staging/v2/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java',
for version in versions: java.bazel_library( service=service, version=version, proto_path=f'/google/privacy/dlp/{version}', bazel_target= f'//google/privacy/dlp/{version}:google-cloud-{service}-{version}-java', destination_name='dlp', ) # TODO: remove this for the next semver major release # remove ResourceName base parseList and toStringList for backward-compatibility with legacy # resource name implementation java.remove_method( "proto-google-cloud-dlp-v2/src/main/java/com/google/privacy/dlp/v2/InspectTemplateName.java", "public static List<InspectTemplateName> parseList(List<String> formattedStrings)" ) java.remove_method( "proto-google-cloud-dlp-v2/src/main/java/com/google/privacy/dlp/v2/InspectTemplateName.java", "public static List<String> toStringList(List<InspectTemplateName> values)" ) java.remove_method( "proto-google-cloud-dlp-v2/src/main/java/com/google/privacy/dlp/v2/DeidentifyTemplateName.java", "public static List<DeidentifyTemplateName> parseList(List<String> formattedStrings)" ) java.remove_method( "proto-google-cloud-dlp-v2/src/main/java/com/google/privacy/dlp/v2/DeidentifyTemplateName.java", "public static List<String> toStringList(List<DeidentifyTemplateName> values)" ) java.remove_method( "proto-google-cloud-dlp-v2/src/main/java/com/google/privacy/dlp/v2/StoredInfoTypeName.java",
def generate_admin_api(gapic): library = gapic.java_library( service='bigtable-admin', version='v2', bazel_target= f'//google/bigtable/admin/v2:google-cloud-bigtable-admin-v2-java', proto_path=f'google/bigtable/admin/v2', ) library = library / 'google-cloud-bigtable-admin-v2-java' # Excludes are relative to source `gapic-google-cloud-bigtable-v2/src` excludes = [ "main/java/com/google/cloud/bigtable/admin/v2/package-info.java", ] # Paths are relative to the destination, which is the current working directory internal_only = [ 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java', 'google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java', ] package_name = f'com.google.cloud.bigtable.admin.v2' java.fix_proto_headers(library / f'proto-google-cloud-bigtable-admin-v2-java') java.fix_grpc_headers( library / f'grpc-google-cloud-bigtable-admin-v2-java', package_name) s.copy(library / f'gapic-google-cloud-bigtable-admin-v2-java/src', 'google-cloud-bigtable/src', excludes=excludes) s.copy(library / f'grpc-google-cloud-bigtable-admin-v2-java/src', f'grpc-google-cloud-bigtable-admin-v2/src') s.copy(library / f'proto-google-cloud-bigtable-admin-v2-java/src', f'proto-google-cloud-bigtable-admin-v2/src') #todo: fix in synthtool removing comments with method java.remove_method( f'./grpc-google-cloud-bigtable-admin-v2/src/main/java/com/google/bigtable/admin/v2/BigtableInstanceAdminGrpc.java', "public UnaryCallSettings<Instance, Instance> updateInstanceSettings()" ) java.remove_method( f'./google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "/** Returns the builder for the settings used for calls to updateInstance. */" ) java.remove_method( f'./google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "public UnaryCallSettings.Builder<Instance, Instance> updateInstanceSettings()" ) java.remove_method( f'./google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "/** Returns the object with the settings used for calls to updateInstance. */" ) java.remove_method( f'./google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', "public UnaryCallSettings<Instance, Instance> updateInstanceSettings()" ) make_internal_only(internal_only) java.format_code(f'./grpc-google-cloud-bigtable-admin-v2/src') java.format_code(f'./proto-google-cloud-bigtable-admin-v2/src')