def collect_resource_name_types(gapic_config, java_package):
    resources = []

    for collection_config in gapic_config.collection_configs.values():
        oneof = get_oneof_for_resource(collection_config, gapic_config)
        resource = resource_name.ResourceName(collection_config, java_package,
                                              oneof)
        resources.append(resource)

    for fixed_config in gapic_config.fixed_collections.values():
        oneof = get_oneof_for_resource(fixed_config, gapic_config)
        resource = resource_name.ResourceNameFixed(fixed_config, java_package,
                                                   oneof)
        resources.append(resource)

    for oneof_config in gapic_config.collection_oneofs.values():
        parent_resource = resource_name.ParentResourceName(
            oneof_config, java_package, oneof_config.pattern_strings)
        untyped_resource = resource_name.UntypedResourceName(
            oneof_config, java_package)
        resource_factory = resource_name.ResourceNameFactory(
            oneof_config, java_package)
        resources.append(parent_resource)
        # Only generate untyped resource class and factory class
        # when generating libraries from gapic config
        if len(resource_factory.single_resource_types) > 0:
            resources.append(untyped_resource)
            resources.append(resource_factory)

    return resources
def collect_resource_name_types(gapic_config, java_package):
    resources = []

    for collection_config in gapic_config.collection_configs.values():
        oneof = get_oneof_for_resource(collection_config, gapic_config)
        resource = resource_name.ResourceName(collection_config, java_package,
                                              oneof)
        resources.append(resource)

    for fixed_config in gapic_config.fixed_collections.values():
        oneof = get_oneof_for_resource(fixed_config, gapic_config)
        resource = resource_name.ResourceNameFixed(fixed_config, java_package,
                                                   oneof)
        resources.append(resource)

    for oneof_config in gapic_config.collection_oneofs.values():
        parent_resource = resource_name.ParentResourceName(
            oneof_config, java_package, oneof_config.pattern_strings)
        untyped_resource = resource_name.UntypedResourceName(
            oneof_config, java_package)
        resource_factory = resource_name.ResourceNameFactory(
            oneof_config, java_package)
        resources.append(parent_resource)
        resources.append(untyped_resource)
        resources.append(resource_factory)

    return resources
def generate_resource_name_types(response, gapic_config, proto_file):
    renderer = pystache.Renderer(search_dirs=TEMPLATE_LOCATION)
    for collection_config in gapic_config.collection_configs.values():
        resource = resource_name.ResourceName(collection_config)
        resource_type = resource_name.ResourceNameType(resource.className())
        render_new_file(renderer, response, resource)
        render_new_file(renderer, response, resource_type)

    for fixed_config in gapic_config.fixed_collections.values():
        resource = resource_name.ResourceNameFixed(fixed_config)
        resource_type = resource_name.ResourceNameType(resource.className())
        render_new_file(renderer, response, resource)
        render_new_file(renderer, response, resource_type)

    for oneof_config in gapic_config.collection_oneofs.values():
        resource_oneof = resource_name.ResourceNameOneof(
            oneof_config, proto_file)
        render_new_file(renderer, response, resource_oneof)
def generate_resource_name_types(response, gapic_config, java_package):
  renderer = pystache.Renderer(search_dirs=TEMPLATE_LOCATION)
  for collection_config in gapic_config.collection_configs.values():
    oneof = get_oneof_for_resource(collection_config, gapic_config)
    resource = resource_name.ResourceName(collection_config, java_package, oneof)
    render_new_file(renderer, response, resource)

  for fixed_config in gapic_config.fixed_collections.values():
    oneof = get_oneof_for_resource(fixed_config, gapic_config)
    resource = resource_name.ResourceNameFixed(fixed_config, java_package, oneof)
    render_new_file(renderer, response, resource)

  for oneof_config in gapic_config.collection_oneofs.values():
    parent_resource = resource_name.ParentResourceName(oneof_config, java_package)
    untyped_resource = resource_name.UntypedResourceName(oneof_config, java_package)
    resource_factory = resource_name.ResourceNameFactory(oneof_config, java_package)
    render_new_file(renderer, response, parent_resource)
    render_new_file(renderer, response, untyped_resource)
    render_new_file(renderer, response, resource_factory)