Return a boolean indicating whether given index template exists

    name
        Index template name

    CLI example::

        salt myminion elasticsearch.index_template_exists testindex_templ
546650
def index_template_exists(name, hosts=None, profile=None):
    '''
    
    '''
    es = _get_instance(hosts, profile)
    try:
        return es.indices.exists_template(name=name)
    except elasticsearch.TransportError as e:
        raise CommandExecutionError("Cannot retrieve template {0}, server returned code {1} with message {2}".format(name, e.status_code, e.error))
928345
def exists(self, index):
        
        data = self.data
        try:
            for c in self._split(index):
                i = int(c) - 1
                data = data[i][4]
        except Exception:
            return False
        return True
275356
private void checkForIndexTemplate() {
        try {
            HttpURLConnection connection = openConnection( "/_template/metrics_template", "HEAD");
            if (connection == null) {
                LOGGER.error("Could not connect to any configured elasticsearch instances: {}", Arrays.asList(hosts));
                return;
            }
            connection.disconnect();

            boolean isTemplateMissing = connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND;

            // nothing there, lets create it
            if (isTemplateMissing) {
                LOGGER.debug("No metrics template found in elasticsearch. Adding...");
                HttpURLConnection putTemplateConnection = openConnection( "/_template/metrics_template", "PUT");
                if(putTemplateConnection == null) {
                    LOGGER.error("Error adding metrics template to elasticsearch");
                    return;
                }

                JsonGenerator json = new JsonFactory().createGenerator(putTemplateConnection.getOutputStream());
                json.writeStartObject();
                json.writeStringField("template", index + "*");
                json.writeObjectFieldStart("mappings");

                json.writeObjectFieldStart("_default_");
                json.writeObjectFieldStart("_all");
                json.writeBooleanField("enabled", false);
                json.writeEndObject();
                json.writeObjectFieldStart("properties");
                json.writeObjectFieldStart("name");
                json.writeObjectField("type", "string");
                json.writeObjectField("index", "not_analyzed");
                json.writeEndObject();
                json.writeEndObject();
                json.writeEndObject();

                json.writeEndObject();
                json.writeEndObject();
                json.flush();

                putTemplateConnection.disconnect();
                if (putTemplateConnection.getResponseCode() != 200) {
                    LOGGER.error("Error adding metrics template to elasticsearch: {}/{}" + putTemplateConnection.getResponseCode(), putTemplateConnection.getResponseMessage());
                }
            }
            checkedForIndexTemplate = true;
        } catch (IOException e) {
            LOGGER.error("Error when checking/adding metrics template to elasticsearch", e);
        }
    }
427578
def template_exists(template_name):
    '''
    
    '''
    try:
        template.loader.get_template(template_name)
        return True
    except template.TemplateDoesNotExist:
        return False
1246309
def copy_template(self, name=None):
        
        ret = Table(self.table_name)
        ret._indexes.update(dict((k, v.copy_template()) for k, v in self._indexes.items()))
        ret(name)
        return ret
704928
def exists(name, path=None):
    '''
    
    '''

    _exists = name in ls_(path=path)
    # container may be just created but we did cached earlier the
    # lxc-ls results
    if not _exists:
        _exists = name in ls_(cache=False, path=path)
    return _exists
589259
def exists(method,
            ip,
            port=None,
            proto='tcp',
            direction='in',
            port_origin='d',
            ip_origin='d',
            ttl=None,
            comment=''):
    '''
    
    '''
    if method.startswith('temp'):
        return _temp_exists(method, ip)
    if port:
        rule = _build_port_rule(ip, port, proto, direction, port_origin, ip_origin, comment)
        return _exists_with_port(method, rule)
    exists = __salt__['cmd.run_all']("egrep ^'{0} +' /etc/csf/csf.{1}".format(ip, method))
    return not bool(exists['retcode'])
228641
def HasIndex(self, index):
        
        for i in self.Items:
            if i.index == index:
                return True
        return False
694054
private static boolean isMappingExist(RestHighLevelClient client, String index) throws Exception {
        GetMappingsResponse mapping = client.indices().getMapping(new GetMappingsRequest().indices(index), RequestOptions.DEFAULT);
        // Let's get the default mapping
        if (mapping.mappings().isEmpty()) {
            return false;
        }
        MappingMetaData doc = mapping.mappings().values().iterator().next();
        return !doc.getSourceAsMap().isEmpty();
    }
668995
def search_template_absent(name):
    '''
    
    '''

    ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}

    try:
        template = __salt__['elasticsearch.search_template_get'](id=name)
        if template:
            if __opts__['test']:
                ret['comment'] = 'Search template {0} will be removed'.format(name)
                ret['changes']['old'] = salt.utils.json.loads(template["template"])
                ret['result'] = None
            else:
                ret['result'] = __salt__['elasticsearch.search_template_delete'](id=name)
                if ret['result']:
                    ret['comment'] = 'Successfully removed search template {0}'.format(name)
                    ret['changes']['old'] = salt.utils.json.loads(template["template"])
                else:
                    ret['comment'] = 'Failed to remove search template {0} for unknown reasons'.format(name)
        else:
            ret['comment'] = 'Search template {0} is already absent'.format(name)
    except Exception as err:
        ret['result'] = False
        ret['comment'] = six.text_type(err)

    return ret
310734
public boolean isExistsIndex(String indexName) {
        IndicesExistsResponse response =
                getClient().admin().indices().exists(
                        new IndicesExistsRequest().indices(new String[]{indexName})).actionGet();
        return response.isExists();
    }
358567
private void initIndex() throws Exception {

        // 0. Add the tasklog template
        GetIndexTemplatesResponse result = elasticSearchClient.admin()
            .indices()
            .prepareGetTemplates("tasklog_template")
            .execute()
            .actionGet();

        if (result.getIndexTemplates().isEmpty()) {
            logger.info("Creating the index template 'tasklog_template'");
            InputStream stream = ElasticSearchDAOV5.class
                .getResourceAsStream("/template_tasklog.json");
            byte[] templateSource = IOUtils.toByteArray(stream);

            try {
                elasticSearchClient.admin()
                    .indices()
                    .preparePutTemplate("tasklog_template")
                    .setSource(templateSource, XContentType.JSON)
                    .execute()
                    .actionGet();
            } catch (Exception e) {
                logger.error("Failed to init tasklog_template", e);
            }
        }
    }
585286
def find_template(self, name, dirs=None):
        
        key = self.cache_key(name, dirs)
        try:
            result = self.find_template_cache[key]
        except KeyError:
            result = None
            for loader in self.loaders:
                try:
                    template, display_name = loader(name, dirs)
                except TemplateDoesNotExist:
                    pass
                else:
                    origin = make_origin(self.engine, display_name, loader, name, dirs)
                    result = template, origin
                    break
        self.find_template_cache[key] = result
        if result:
            return result
        else:
            self.template_cache[key] = TemplateDoesNotExist
            raise TemplateDoesNotExist(name)
730837
def template_stack(name=None, profile=None):
    '''
    
    '''
    h_client = _auth(profile)

    if not name:
        return {
            'result': False,
            'comment':
                'Parameter name missing or None'
            }
    try:
        get_template = h_client.stacks.template(name)
    except heatclient.exc.HTTPNotFound:
        return {
            'result': False,
            'comment': 'No stack with {0}'.format(name)
            }
    except heatclient.exc.BadRequest:
        return {
            'result': False,
            'comment': 'Bad request fot stack {0}'.format(name)
            }
    if 'heat_template_version' in get_template:
        template = salt.utils.yaml.safe_dump(get_template)
    else:
        template = jsonutils.dumps(get_template, indent=2, ensure_ascii=False)

    checksum = __salt__['hashutil.digest'](template)
    ret = {
        'template': template,
        'result': True,
        'checksum': checksum
    }
    return ret
1294156
def has_template(self, uri):
        
        try:
            self.get_template(uri)
            return True
        except exceptions.TemplateLookupException:
            return False
1175829
function indexTemplate(format, data) {
  if (format === 'cjs') {
    return `module.exports = require('${data.main}')`
  }
  if (format === 'esm') {
    return `import ${data.name} from '${data.main}'

export default ${data.name}`
  }
}
1096445
def search_template_get(id, hosts=None, profile=None):
    '''
    
    '''
    es = _get_instance(hosts, profile)

    try:
        return es.get_template(id=id)
    except elasticsearch.NotFoundError:
        return None
    except elasticsearch.TransportError as e:
        raise CommandExecutionError("Cannot obtain search template {0}, server returned code {1} with message {2}".format(id, e.status_code, e.error))