Use of service with Python

Program: s3CreateBucket.py s3CreateBucket.py
Parameters:

  • Access Key.
  • BucketName.

Execution when number or buckets is exceeded:

python s3CreateBucket.py XXXX  buckecillo
    PARAMETERS: Access Key <XXXX Bucket <buckecillo>.
    !!! WARNING Bucket buckecillo can not be created.
    Review S3ResponseError: 400 Bad Request
    <?xml version="1.0" encoding="UTF-8"?><Error><Code>TooManyBuckets</Code><BucketName>buckecillo</BucketName><RequestId>tx00000000000000000472c-005e6a087f-196c5-default</RequestId><HostId>196c5-default-default</HostId></Error> log information.
    Please attention to field CODE if exists

Successfully execution:

python s3CreateBucket.py XXXX buckecillo
    PARAMETERS: Access Key XXXX Bucket <buckecillo>.
    Bucket buckecillo created successfully.

Program: s3CreateKey.py s3CreateKey.py
Parameters:

  • Access Key.
  • BucketName.
  • KeyName.
  • FileName: Absolute path of file associated to key.
  • Is Private 0 Public /1 Private.
  • ExpirationTime: Time on seconds to expiration URL (Private mode).

Execution when file does not exist:

python s3CreateKey.py XXXXX buckecillo pepe xx.csv 0 280
    PARAMETERS: Access Key <XXXXX> Bucket Name <buckecillo> Key Name <pepe> File Name <xx.csv> Is Private (0 Not/1 Yes) <0> ExpirationTime (0 not expiration) <280>.
    File <xx.csv> does not exist. Key pepe can be created on bucket buckecillo

Execution to assign key to a bucket which does not exit:

python s3CreateKey.py  XXXXX buckecillo pepe data.csv 0 280
    PARAMETERS: Access Key  <XXXXX> Bucket Name <buckecillo> Key Name <pepe> File Name <data.csv> Is Private (0 Not/1 Yes) <0> ExpirationTime (0 not expiration) <280>.
    Bucket, whose name is buckecillo, does not exist

Execution when quota is exceeded:

python s3CreateKey.py XXXXX buckecillo pepe /home/cephuser/data/data.csv 0 280
    PARAMETERS: Access Key <XXXXX> Bucket Name <buckecillo> Key Name <pepe> File Name </home/cephuser/data/data.csv> Is Private (0 Not/1 Yes) <0> ExpirationTime (0 not expiration) <280>.
    !!! KEY WARNING. Error during key pepe creation.  
    Error description S3ResponseError: 403 Forbidden
    <?xml version="1.0" encoding="UTF-8"?><Error><Code>QuotaExceeded</Code><BucketName>buckecillo</BucketName><RequestId>tx000000000000000004b06-005e6a1b18-196b3-default</RequestId><HostId>196b3-default-default</HostId></Error>.
    Review field CODE

Successfully creation:

python s3CreateKey.py XXXXX buckecillo pepe /home/cephuser/data/data.csv 0 280
    PARAMETERS: Access Key <XXXXX> Bucket Name <buckecillo> Key Name <pepe> File Name </home/cephuser/data/data.csv> Is Private (0 Not/1 Yes) <0> ExpirationTime (0 not expiration) <280>.
    Key pepe on bucket buckecillo created on mode public-read and security False. If it is secure, its expiration time is 0.
    URL associated is: https://ss3.scayle.es:443/buckecillo/pepe
    Key pepe associated to Bucket buckecillo created successfully.

Go to your browser and navigate to the URL associated:  
    https://ss3.scayle.es:443/buckecillo/pepe
    * On Explorer and Firefox browser will appear a message whick ask you about open or save the file associated to the key
    * On Chrome the browser download the file and you can access to the file associated to the key on the download folder of the machine which is using the OpenCayle service.

Program: s3DeleteKey.py s3DeleteKey.py
Parameters:

  • Access Key.
  • BucketName.
  • BucketKey.

Execution when the bucket does not exist:

python s3DeleteKey.py XXXX  buckecillo pepe
    PARAMETERS: Access Key <XXXX> Bucket Name <buck> Key Name <pepe>.
    Bucket buck or Key pepe associated to this bucket does not exist. Please review your S3 data.

Execution when the key does not exist but the bucket exist:

python s3DeleteKey.py XXXX  buckecillo dolores
    PARAMETERS: Access Key <XXXX> Bucket Name <buckecillo> Key Name <dolores>.
    Bucket buckecillo or Key dolores associated to this bucket does not exist. Please review your S3 data.

Successfully key deletion:

python s3DeleteKey.py XXXX  buckecillo pepe
    PARAMETERS: Access Key <XXXX> Bucket Name <buckecillo> Key Name <pepe>.
    Key pepe deleted from bucket buckecillo successfully

Program: s3DeleteBucket.py s3DeleteBucket.py
Parameters:

  • Access Key.
  • BucketName.

Execution when bucket does not exist:

python s3DeleteBucket.py XXXXX  buckell
    PARAMETERS: Access Key  XXXXX Bucket <buckell>.
    Bucket buckell does not exist. Please review your S3 data

Execution when bucket exists and have keys associated:

Step 1) Create a new key associated to the bucket.

python s3CreateKey.py XXXXX buckecillo lola /home/cephuser/data/data.csv 0 280
    PARAMETERS: Access Key <XXXXX> Bucket Name <buckecillo> Key Name <pepe> File Name </home/cephuser/data/data.csv> Is Private (0 Not/1 Yes) <0> ExpirationTime (0 not expiration) <280>.
    Key pepe on bucket buckecillo created on mode public-read and security False. If it is secure, its expiration time is 0.
    URL associated is: https://ss3.scayle.es:443/buckecillo/lola
    Key lola associated to Bucket buckecillo created successfully.

Step 2) Delete bucket which contains the key created on step 1.

python s3DeleteBucket.py XXXXX buckecillo
    PARAMETERS: Access Key <XXXXX> Bucket <buckecillo>.
    Bucket buckecillo deleted successfully. All their keys were deleted previously

Program: s3Resources.py s3Resources.py
Parameters:

  • Access Key.

Show information when user connection information is wrong:

python s3Resources.py  XX
    PARAMETERS: Access Key <XX>
    boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
    <?xml version="1.0" encoding="UTF-8"?><Error><Code>AccessDenied</Code><RequestId>tx000000000000000004fbf-005e6a2b79-196b3-default</RequestId><HostId>196b3-default-default</HostId></Error>

Show information when user connection information is correct:

python s3Resources.py  XXXX
    PARAMETERS: Access Key <XXXX>
    -----------------------------------------------------------------------------------------
                         Open Scayle Resources associated to user.  
    -----------------------------------------------------------------------------------------
    - BUCKET bucket1 2020-03-12T12:22:39.216Z
        - KEY alejandra 12  2020-03-12T12:24:01.011Z
        - KEY alex  12  2020-03-12T12:23:53.648Z
    - BUCKET bucket2 2020-03-12T12:22:42.362Z
        - KEY juan  12  2020-03-12T12:23:28.295Z
        - KEY lola  12  2020-03-12T12:23:43.375Z
    -----------------------------------------------------------------------------------------
                            END Open Scayle Resources