Ejemplo n.º 1
0
    def execute(self, language, toolkit_path, descriptor_set, service_yaml,
                gapic_yaml, package_metadata_yaml,
                gapic_code_dir, api_name, api_version, organization_name,
                aspect, generator_args):
        existing = glob.glob('%s/*' % gapic_code_dir)
        if existing:
            self.exec_command(['rm', '-r'] + existing)
        gapic_args = ['--gapic_yaml=' + os.path.abspath(gapic_yaml)]
        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
            '--output=' + os.path.abspath(gapic_code_dir),
            '--language=' + language,
        ]
        if service_yaml:
            args = args + ['--service_yaml=' + os.path.abspath(service_yaml)]
        args = args + gapic_args

        if generator_args:
          args = args + generator_args.split(' ')

        gapic_artifact = ''
        if aspect == 'ALL':
            gapic_artifact = 'LEGACY_GAPIC_AND_PACKAGE'
        elif aspect == 'CODE':
            gapic_artifact = 'GAPIC_CODE'
        elif aspect == 'PACKAGE':
            gapic_artifact = 'GAPIC_PACKAGE'
        else:
            raise ValueError('GapicCodeGenTask: no generation turned on')

        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, [gapic_artifact] + args))

        return gapic_code_dir
Ejemplo n.º 2
0
    def _execute(self, api_name, api_version, organization_name, toolkit,
                 descriptor_set, src_proto_path, service_yaml, input_dir,
                 output_dir, package_metadata_yaml, language, artifact_type):
        toolkit_path = toolkit
        api_full_name = task_utils.api_full_name(api_name, api_version,
                                                 organization_name)
        proto_prefix = self._get_proto_prefix()

        pkg_dir = os.path.join(output_dir, language,
                               proto_prefix + api_full_name)

        service_args = [
            '--service_yaml=' + os.path.abspath(yaml) for yaml in service_yaml
        ]
        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--input=' + os.path.abspath(input_dir),
            '--output=' + os.path.abspath(pkg_dir),
            '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
            '--artifact_type=' + artifact_type,
            '--language=' + language,
        ] + service_args
        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path,
                                      ['LEGACY_GRPC_PACKAGE'] + args))

        return pkg_dir
Ejemplo n.º 3
0
    def execute(self, language, toolkit_path, descriptor_set, service_yaml,
                gapic_yaml, package_metadata_yaml, gapic_code_dir, api_name,
                api_version, organization_name, aspect):
        existing = glob.glob('%s/*' % gapic_code_dir)
        if existing:
            self.exec_command(['rm', '-r'] + existing)
        gapic_args = ['--gapic_yaml=' + os.path.abspath(gapic_yaml)]
        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
            '--output=' + os.path.abspath(gapic_code_dir),
            '--language=' + language,
        ]
        if service_yaml:
            args = args + ['--service_yaml=' + os.path.abspath(service_yaml)]
        args = args + gapic_args

        gapic_artifact = ''
        if aspect == 'ALL':
            gapic_artifact = 'LEGACY_GAPIC_AND_PACKAGE'
        elif aspect == 'CODE':
            gapic_artifact = 'GAPIC_CODE'
        elif aspect == 'PACKAGE':
            gapic_artifact = 'GAPIC_PACKAGE'
        else:
            raise ValueError('GapicCodeGenTask: no generation turned on')

        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, [gapic_artifact] + args))

        return gapic_code_dir
Ejemplo n.º 4
0
    def execute(self, language, toolkit_path, descriptor_set, service_yaml,
                gapic_api_yaml, package_metadata_yaml, gapic_code_dir,
                api_name, api_version, organization_name):
        existing = glob.glob('%s/*' % gapic_code_dir)
        if existing:
            self.exec_command(['rm', '-r'] + existing)
        gapic_yaml = gapic_api_yaml
        gapic_args = [
            '--gapic_yaml=' + os.path.abspath(yaml) for yaml in gapic_yaml
        ]
        service_args = [
            '--service_yaml=' + os.path.abspath(yaml) for yaml in service_yaml
        ]
        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
            '--output=' + os.path.abspath(gapic_code_dir),
            '--language=' + language,
        ] + service_args + gapic_args

        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path,
                                      ['LEGACY_GAPIC_AND_PACKAGE'] + args))

        return gapic_code_dir
Ejemplo n.º 5
0
    def execute(self, toolkit_path, discovery_doc,
        output_dir, api_name, api_version, organization_name):
        api_full_name = task_utils.api_full_name(
            api_name, api_version, organization_name)
        config_gen_dir = os.path.join(
            output_dir, api_full_name + '-config-gen')
        self.exec_command(['mkdir', '-p', config_gen_dir])
        config_gen_path = os.path.join(config_gen_dir,
                                       api_full_name + '_gapic.yaml')
        args = [
            '--discovery_doc=' + os.path.abspath(
                os.path.expanduser(discovery_doc)),
            '--output=' + os.path.abspath(config_gen_path)
        ]
        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, ['DISCOGAPIC_CONFIG'] + args))

        return config_gen_path
Ejemplo n.º 6
0
    def execute(self, language, toolkit_path, discovery_doc,
        gapic_yaml, package_metadata_yaml,
        gapic_code_dir, api_name, api_version, organization_name, root_dir):
        existing = glob.glob('%s/*' % gapic_code_dir)
        if existing:
            self.exec_command(['rm', '-r'] + existing)
        gapic_args = ['--gapic_yaml=' + os.path.abspath(gapic_yaml)]
        args = [
                   '--discovery_doc=' + os.path.join(root_dir, discovery_doc),
                   '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
                   '--output=' + os.path.abspath(gapic_code_dir),
                   '--language=' + language,
                   ] + gapic_args

        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, ['LEGACY_DISCOGAPIC_AND_PACKAGE'] + args))

        return gapic_code_dir
Ejemplo n.º 7
0
    def execute(self, toolkit_path, discovery_doc, output_dir, api_name,
                api_version, organization_name):
        api_full_name = task_utils.api_full_name(api_name, api_version,
                                                 organization_name)
        config_gen_dir = os.path.join(output_dir,
                                      api_full_name + '-config-gen')
        self.exec_command(['mkdir', '-p', config_gen_dir])
        config_gen_path = os.path.join(config_gen_dir,
                                       api_full_name + '_gapic.yaml')
        args = [
            '--discovery_doc=' +
            os.path.abspath(os.path.expanduser(discovery_doc)),
            '--output=' + os.path.abspath(config_gen_path)
        ]
        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path,
                                      ['DISCOGAPIC_CONFIG'] + args))

        return config_gen_path
Ejemplo n.º 8
0
    def execute(self, toolkit_path, descriptor_set, service_yaml, output_dir,
                api_name, api_version, organization_name):
        api_full_name = task_utils.api_full_name(api_name, api_version,
                                                 organization_name)
        config_gen_dir = os.path.join(output_dir,
                                      api_full_name + '-config-gen')
        self.exec_command(['mkdir', '-p', config_gen_dir])
        config_gen_path = os.path.join(config_gen_dir,
                                       api_full_name + '_gapic.yaml')
        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--output=' + os.path.abspath(config_gen_path),
        ]
        if service_yaml:
            args = args + ['--service_yaml=' + os.path.abspath(service_yaml)]
        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, ['GAPIC_CONFIG'] + args))

        return config_gen_path
Ejemplo n.º 9
0
    def execute(self, language, toolkit_path, discovery_doc, gapic_yaml,
                package_metadata_yaml, gapic_code_dir, api_name, api_version,
                organization_name, root_dir):
        existing = glob.glob('%s/*' % gapic_code_dir)
        if existing:
            self.exec_command(['rm', '-r'] + existing)
        gapic_args = ['--gapic_yaml=' + os.path.abspath(gapic_yaml)]
        args = [
            '--discovery_doc=' + os.path.join(root_dir, discovery_doc),
            '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
            '--output=' + os.path.abspath(gapic_code_dir),
            '--language=' + language,
        ] + gapic_args

        self.exec_command(
            task_utils.gapic_gen_task(
                toolkit_path, ['LEGACY_DISCOGAPIC_AND_PACKAGE'] + args))

        return gapic_code_dir
Ejemplo n.º 10
0
    def execute(self, toolkit_path, descriptor_set, service_yaml,
                output_dir, api_name, api_version, organization_name):
        api_full_name = task_utils.api_full_name(
            api_name, api_version, organization_name)
        config_gen_dir = os.path.join(
            output_dir, api_full_name + '-config-gen')
        self.exec_command(['mkdir', '-p', config_gen_dir])
        config_gen_path = os.path.join(config_gen_dir,
                                       api_full_name + '_gapic.yaml')
        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--output=' + os.path.abspath(config_gen_path),
        ]
        if service_yaml:
            args = args + ['--service_yaml=' + os.path.abspath(service_yaml)]
        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, ['GAPIC_CONFIG'] + args))

        return config_gen_path
Ejemplo n.º 11
0
    def execute(self,
                language,
                toolkit_path,
                descriptor_set,
                service_yaml,
                gapic_yaml,
                package_metadata_yaml,
                proto_package,
                gapic_code_dir,
                api_name,
                api_version,
                organization_name,
                aspect,
                samples,
                generator_args,
                grpc_service_config=''):
        existing = glob.glob('%s/*' % gapic_code_dir)
        if existing:
            self.exec_command(['rm', '-r'] + existing)
        gapic_args = []
        if proto_package:
            gapic_args.append('--package=' + proto_package)
        if gapic_yaml:
            gapic_args.append('--gapic_yaml=' + os.path.abspath(gapic_yaml))
        if samples:
            sample_yamls = self._get_sample_yamls(samples)
            if sample_yamls:
                gapic_args.append('--sample_yamls')
                for sample_yaml in sample_yamls:
                    gapic_args.append(sample_yaml)
        if grpc_service_config:
            gapic_args.append('--grpc_service_config=' +
                              os.path.abspath(grpc_service_config))

        args = [
            '--descriptor_set=' + os.path.abspath(descriptor_set),
            '--package_yaml2=' + os.path.abspath(package_metadata_yaml),
            '--output=' + os.path.abspath(gapic_code_dir),
            '--language=' + language,
        ]
        if service_yaml:
            args = args + ['--service_yaml=' + os.path.abspath(service_yaml)]
        args = args + gapic_args

        if generator_args:
            args = args + generator_args.split(' ')

        gapic_artifact = ''
        if aspect == 'ALL':
            gapic_artifact = 'LEGACY_GAPIC_AND_PACKAGE'
        elif aspect == 'CODE':
            gapic_artifact = 'GAPIC_CODE'
        elif aspect == 'PACKAGE':
            gapic_artifact = 'GAPIC_PACKAGE'
        else:
            raise ValueError('GapicCodeGenTask: no generation turned on')

        self.exec_command(
            task_utils.gapic_gen_task(toolkit_path, [gapic_artifact] + args))

        return gapic_code_dir