storj.http module

Storj HTTP module.

class Client(email, password)[source]

Bases: object

api_url

str – the Storj API endpoint.

session
email

str – user email address.

password

str – user password.

private_key
public_key
public_key_hex
authenticate(ecdsa_private_key=None)[source]
bucket_create(name, storage=None, transfer=None)[source]

Create storage bucket.

See API buckets: POST /buckets

Parameters:
  • name (str) – name.
  • storage (int) – storage limit (in GB).
  • transfer (int) – transfer limit (in GB).
Returns:

bucket.

Return type:

(model.Bucket)

bucket_delete(bucket_id)[source]

Destroy a storage bucket.

See API buckets: DELETE /buckets/{id}

Parameters:bucket_id (string) – unique identifier.
bucket_files(bucket_id)[source]

List all the file metadata stored in the bucket.

See API buckets: GET /buckets/{id}/files

Parameters:bucket_id (string) – unique identifier.
Returns:to be changed to model in the future.
Return type:(dict)
bucket_get(bucket_id)[source]

Return the bucket object.

See API buckets: GET /buckets

Parameters:bucket_id (str) – bucket unique identifier.
Returns:bucket.
Return type:(model.Bucket)
bucket_list()[source]

List all of the buckets belonging to the user.

See API buckets: GET /buckets

Returns:buckets.
Return type:(generator[model.Bucket])
bucket_set_keys(bucket_id, bucket_name, keys)[source]

Update the bucket with the given public keys.

See API buckets: PATCH /buckets/{bucket_id}

Parameters:
  • bucket_id (str) – bucket unique identifier.
  • bucket_name (str) – bucket name.
  • keys (list[str]) – public keys.
Returns:

updated bucket information.

Return type:

(storj.model.Bucket)

bucket_set_mirrors(bucket_id, file_id, redundancy)[source]

Establishes a series of mirrors for the given file.

See API buckets: POST /buckets/{id}/mirrors

Parameters:
  • bucket_id (str) – bucket unique identifier.
  • file_id (str) – file unique identitifer.
  • redundancy (int) – number of replicas.
Returns:

the mirror settings.

Return type:

(storj.model.Mirror)

contact_list(page=1, address=None, protocol=None, user_agent=None, connected=None)[source]

Lists contacts.

See API contacts: GET /contacts

Parameters:
  • page (str) – pagination indicator.
  • address (str) – hostname or IP address.
  • protocol (str) – SemVer protocol tag.
  • user_agent (str) – Storj user agent string for farming client.
  • connected (bool) – filter results by connection status.
Returns:

list of contacts.

Return type:

(list[storj.model.Contact])

contact_lookup(node_id)[source]

Lookup for contact information of a node.

See API contacts: GET /contacts/{nodeID}

Parameters:node_id (str) – node unique identifier.
Returns:contact information
Return type:(storj.model.Contact)
file_download(bucket_id, file_id)[source]
file_metadata(bucket_id, file_id)[source]

Get file metadata.

See API buckets: GET /buckets/{id}/files/{file_id}/info

Parameters:
  • bucket_id (str) – bucket unique identifier.
  • file_id (str) – file unique identifier.
Returns:

file metadata.

Return type:

(storj.model.File)

file_pointers(bucket_id, file_id, skip=None, limit=None)[source]

Get list of pointers associated with a file.

See API buckets: GET /buckets/{id}/files/{file_id}

Parameters:
  • bucket_id (str) – bucket unique identifier.
  • file_id (str) – file unique identifier.
  • skip (str) – pointer index to start the file slice.
  • limit (str) – number of pointers to resolve tokens for.
Returns:

file pointers.

Return type:

(generator[storj.model.FilePointer])

file_remove(bucket_id, file_id)[source]

Delete a file pointer from a specified bucket.

See API buckets: DELETE /buckets/{id}/files/{file_id}

Parameters:
  • bucket_id (str) – bucket unique identifier.
  • file_id (str) – file unique identifier.
file_upload(bucket_id, file, frame)[source]

Upload file.

See API buckets: POST /buckets/{id}/files

Parameters:
frame_add_shard(shard, frame_id)[source]

Adds a shard item to the staging frame and negotiates a storage contract.

See API frames: PUT /frames/{frame_id}

Parameters:
  • shard (storj.models.Shard) – the shard.
  • frame_id (str) – the frame unique identifier.
frame_create()[source]

Creates a file staging frame.

See API frames: POST /frames

Returns:the frame.
Return type:(storj.model.Frame)
frame_delete(frame_id)[source]

Destroys the file staging frame by it’s unique ID.

See API frames: DELETE /frames/{frame_id}

Parameters:frame_id (str) – unique identifier.
frame_get(frame_id)[source]

Fetches the file staging frame by it’s unique ID.

See API frame: GET /frames/{frame_id}

Parameters:frame_id (str) – unique identifier.
Returns:a frame.
Return type:(storj.model.Frame)
frame_list()[source]

Returns all open file staging frames.

See `API frame: GET /frames < https://storj.github.io/bridge/#!/frames/get_frames>`_

Returns:all open file staging frames.
Return type:(generator[storj.model.Frame])
key_delete(public_key)[source]

Removes a public ECDSA keys.

See API keys: DELETE /keys/{pubkey}

Parameters:public_key (str) – key to be removed.
key_dump()[source]
key_export()[source]
key_generate()[source]
key_import(private_keyfile_path, public_keyfile_path)[source]
key_list()[source]

Lists the public ECDSA keys associated with the user.

See API keys: GET /keys

Returns:public keys.
Return type:(list[str])
key_register(public_key)[source]

Register an ECDSA public key.

See API keys: POST /keys

Returns:public keys.
Return type:(list[storj.model.Key])
logger = <logging.Logger object>
password

(str) – user password

token_create(bucket_id, operation)[source]

Creates a token for the specified operation.

See API buckets: POST /buckets/{id}/tokens

Parameters:
  • bucket_id (str) – bucket unique identifier.
  • operation (str) – operation.
Returns:

...

Return type:

(dict)

user_activate(token)[source]

Activate user.

See API users: GET /activations/{token}

Parameters:token (str) – activation token.
user_activation_email(email, token)[source]

Send user activation email.

See API users: POST /activations/{token}

Parameters:
  • email (str) – user’s email address.
  • token (str) – activation token.
user_create(email, password)[source]

Create a new user with Storj bridge.

See API users: POST /users

Parameters:
  • email (str) – user’s email address.
  • password (str) – user’s password.
user_deactivate(token)[source]

Discard activation token.

See API users: GET /activations/{token}

Parameters:token (str) – activation token.
user_delete(email)[source]

Delete user account.

See API users: DELETE /users/{email}

Parameters:email (str) – user’s email address.
user_reset_password(email)[source]

Request a password reset.

See API users: PATCH /users/{email}

Parameters:email (str) – user’s email address.
user_reset_password_confirmation(token)[source]

Confirm a password reset request.

See API users: GET /resets/{token}

Parameters:token (str) – password reset token.