Handle index creation command

@param Client $client
@param string $index
@param string $alias
979759
public function handle(Client $client, $index, $alias)
    {
        $config = $this->configurations->get($alias);

        if (null === $config) {
            throw new \InvalidArgumentException();
        }

        $client->getIndex($index)->create($config);
    }
105898
final public function hasIndex(string $alias): bool
    {
        $this->loadIndexes();
        return isset($this->gsi[$alias]);
    }
140906
public function createQueryBuilder($alias, $indexBy = null)
    {
        return $this->em->createQueryBuilder()
            ->select($alias)
            ->from($this->entityName, $alias, $indexBy);
    }
912764
def index(self, alias):
        
        clone = self._clone()
        clone._index = alias
        return clone
670124
public int swapIndex(final String index,
                       final String alias) throws IndexException {
    //IndicesAliasesResponse resp = null;
    try {
      /* index is the index we were just indexing into
       */

      final IndicesAdminClient idx = getAdminIdx();

      final GetAliasesRequestBuilder igarb = idx.prepareGetAliases(
              alias);

      final ActionFuture<GetAliasesResponse> getAliasesAf =
              idx.getAliases(igarb.request());
      final GetAliasesResponse garesp = getAliasesAf.actionGet();

      final ImmutableOpenMap<String, List<AliasMetaData>> aliasesmeta =
              garesp.getAliases();

      final IndicesAliasesRequestBuilder iarb = idx.prepareAliases();

      final Iterator<String> it = aliasesmeta.keysIt();

      while (it.hasNext()) {
        final String indexName = it.next();

        for (final AliasMetaData amd: aliasesmeta.get(indexName)) {
          if(amd.getAlias().equals(alias)) {
            iarb.removeAlias(indexName, alias);
          }
        }
      }

      iarb.addAlias(index, alias);

      final ActionFuture<IndicesAliasesResponse> af =
              idx.aliases(iarb.request());

      /*resp = */af.actionGet();

      return 0;
    } catch (final ElasticsearchException ese) {
      // Failed somehow
      error(ese);
      return -1;
    } catch (final IndexException ie) {
      throw ie;
    } catch (final Throwable t) {
      throw new IndexException(t);
    }
  }
416916
def create_index(self, index=None, settings=None, es=None):
        """"""
        if index is None:
            index = self.index
        if es is None:
            es = self.es
        try:
            alias = index
            index = generate_index_name(alias)

            args = {'index': index}
            if settings:
                args['body'] = settings

            es.indices.create(**args)
            es.indices.put_alias(index, alias)
            logger.info('created index alias=%s index=%s' % (alias, index))
        except elasticsearch.TransportError:  # index exists
            pass
92816
def get_client_index_from_id(self, client_id):
        """"""
        for index, client in enumerate(self.clients):
            if id(client) == client_id:
                return index
930672
@Deprecated
	public static boolean isIndexExist(Client client, String index) {
		return client.admin().indices().prepareExists(index).get().isExists();
	}
917753
public function handle(Client $client, $index, $type, $alias = null)
    {
        $alias = $alias ?: $index;

        $entries = $this->registry->get($alias, $type);

        $this->dispatchHandlingStartedEvent($entries);

        foreach ($entries as $entry) {
            $this->dispatchProvidingStartedEvent($entry);

            $entry->getProvider()->run(
                $client,
                $index,
                $entry->getType(),
                $this->dispatcher
            );

            $this->dispatchProvidingFinishedEvent($entry);
        }
    }
1209666
public void write(final AbstractIndex index)
		throws SQLException
	{

		Statement statement;
		StringBuilder cmd;

		while (index.size() > 0) {

			System.out.println("Transmit Index [" + index + "]");

			cmd = index.remove();
			// System.out.println(cmd.toString());

			statement = connection.createStatement();
			statement.execute(cmd.toString());
			statement.close();
		}
	}
1121034
public function updateClient(ClientInterface $client)
    {
        if (isset($this->clients[$client->getAccessToken()])) {
            $this->clients[$client->getAccessToken()] = $client;
        }
    }
795544
def do_index_command(self, index, **options):
        """"""
        if options["interactive"]:
            logger.warning("This will permanently delete the index '%s'.", index)
            if not self._confirm_action():
                logger.warning(
                    "Aborting rebuild of index '%s' at user's request.", index
                )
                return

        try:
            delete = delete_index(index)
        except TransportError:
            delete = {}
            logger.info("Index %s does not exist, cannot be deleted.", index)
        create = create_index(index)
        update = update_index(index)

        return {"delete": delete, "create": create, "update": update}
420958
def create(index_name, body, force, verbose):
    """"""
    result = current_search_client.indices.create(
        index=index_name,
        body=json.load(body),
        ignore=[400] if force else None,
    )
    if verbose:
        click.echo(json.dumps(result))
648263
final public function create(DynamoDbClient $client, string $tableName): void
    {
        try {
            $client->describeTable(['TableName' => $tableName]);
            return;
        } catch (DynamoDbException $e) {
            // table doesn't exist, create it below
        }

        $this->loadIndexes();

        $attributes = [];
        $indexes = [];

        foreach ($this->gsi as $gsi) {
            foreach ($gsi->getKeyAttributes() as $definition) {
                $attributes[$definition['AttributeName']] = $definition;
            }

            $indexName = $gsi->getName();
            $indexes[$indexName] = [
                'IndexName'             => $indexName,
                'KeySchema'             => [
                    ['AttributeName' => $gsi->getHashKeyName(), 'KeyType' => 'HASH'],
                ],
                'Projection'            => $gsi->getProjection() ?: ['ProjectionType' => 'KEYS_ONLY'],
                'ProvisionedThroughput' => $this->getDefaultProvisionedThroughput(),
            ];

            if ($gsi->getRangeKeyName()) {
                $indexes[$indexName]['KeySchema'][] = ['AttributeName' => $gsi->getRangeKeyName(), 'KeyType' => 'RANGE'];
            }
        }

        $attributes[self::HASH_KEY_NAME] = ['AttributeName' => self::HASH_KEY_NAME, 'AttributeType' => 'S'];
        $attributes = array_values($attributes);
        $indexes = array_values($indexes);

        try {
            $client->createTable([
                'TableName'              => $tableName,
                'AttributeDefinitions'   => $attributes,
                'KeySchema'              => [
                    ['AttributeName' => self::HASH_KEY_NAME, 'KeyType' => 'HASH'],
                ],
                'GlobalSecondaryIndexes' => $indexes,
                'StreamSpecification'    => [
                    'StreamEnabled'  => true,
                    'StreamViewType' => 'NEW_AND_OLD_IMAGES',
                ],
                'ProvisionedThroughput'  => $this->getDefaultProvisionedThroughput(),
            ]);

            $client->waitUntil('TableExists', ['TableName' => $tableName]);
        } catch (\Throwable $e) {
            throw new RepositoryOperationFailed(
                sprintf(
                    '%s::Unable to create table [%s] in region [%s].',
                    ClassUtils::getShortName($this),
                    $tableName,
                    $client->getRegion()
                ),
                Code::INTERNAL,
                $e
            );
        }
    }
263123
private boolean createIndex(String index, Map<String, Object> defaultSettings) {
        IndicesExistsResponse res = client.admin().indices().prepareExists(index).execute().actionGet();
        boolean created = false;
        if (!res.isExists()) {
            CreateIndexRequestBuilder req = client.admin().indices().prepareCreate(index);
            req.setSettings(defaultSettings);
            created = req.execute().actionGet().isAcknowledged();
            if (!created) {
                throw new RuntimeException("Could not create index [" + index + "]");
            }
        }

        return created;
    }
405729
private function addScopeAndRedirectUris(Client $client): void
    {
        $client->setScopeIdentifiers($this->readScopeIdentifiers($client->getIdentifier()));
        $client->setRedirectUriStrings($this->readRedirectUriStrings($client->getIdentifier()));
    }
83234
private function initializeClient($url, ClientInterface $client = null)
    {
        if ($client) {
            $this->client = $client;
        } else {
            $this->client = new LocalClient($url);
        }
    }