Skip to content

Latest commit

 

History

History

CreateNewBucket

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

CreateNewBucket

This is an example how to create new bucket with permission to write.

Prerequisites:

  • Docker
  • Cloned examples:
    git clone [email protected]:influxdata/influxdb-client-swift.git
    cd Examples/CreateNewBucket

Sources:

How to test:

  1. Start InfluxDB:
    docker run --rm \
      --name influxdb_v2 \
      --detach \
      --publish 8086:8086 \
      influxdb:latest
  2. Configure your username, password, organization, bucket and token:
    docker run --rm \
       --link influxdb_v2 \
       curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \
          -H 'accept: application/json' \
          -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}'
  3. Start SwiftCLI by:
     docker run --rm \
       --link influxdb_v2 \
       --privileged \
       --interactive \
       --tty \
       --volume $PWD/../..:/client \
       --workdir /client/Examples/CreateNewBucket \
       swift:5.7 /bin/bash
  4. Create a new Bucket by:
    swift run create-new-bucket --name new-bucket --org my-org --token my-token --url http://influxdb_v2:8086

Expected output

The bucket: 'new-bucket' is successfully created.
The following token could be use to read/write:
        224axj_OaOOVIaEnSQgx2GTrrt18ZqUATS1I0Hsha3M7Bbbsn_yX9EiXTMnlq5aHz-f8h9iNcRJGd1_ImAD7fA==