Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ var/
sdist/
develop-eggs/
.installed.cfg
venv/

# Installer logs
pip-log.txt
Expand Down
100 changes: 48 additions & 52 deletions IronBoxCreateRemoveSFTContainer.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,58 @@
#!/usr/bin/python
#---------------------------------------------------
#
# Demonstrates how to create and remove an IronBox
# secure file transfer container
#
# Written by KevinLam@goironbox.com
# Website: www.goironbox.com
#
#---------------------------------------------------
from IronBoxREST import IronBoxRESTClient
"""
Demonstrates how to create and remove an IronBox
secure file transfer container

Written by KevinLam@goironbox.com
Modified by motorific@gmail.com
Website: www.goironbox.com
"""

from IronBoxREST import IronBoxRESTClient
from IronBoxREST import IronBoxSFTContainerConfig

#---------------------------------------------------
# ---------------------------------------------------
# Your IronBox authentication parameters, you could
# also pass these in as command arguments
#---------------------------------------------------
IronBoxEmail = "email@email.com"
IronBoxPassword = "password123"
IronBoxAPIVersion = "latest"
# ---------------------------------------------------
ironbox_email = "email@email.com"
ironbox_pwd = "password123"
ironbox_api_version = "latest"

# Default context, otherwise use your IronBox context
# Default context, otherwise use your IronBox context
# instance, i.e., your_company.goironcloud.com
Context = "secure.goironcloud.com"
context = "secure.goironcloud.com"


#---------------------------------------------------
# Main
#---------------------------------------------------
def main():

#--------------------------------------------------
# Create an instance of the IronBox REST class
#--------------------------------------------------
IronBoxRESTObj = IronBoxRESTClient(IronBoxEmail, IronBoxPassword, version=IronBoxAPIVersion, verbose=True)

#--------------------------------------------------
# Create the container, duplicate container names
# are supported
#--------------------------------------------------
ContainerConfig = IronBoxSFTContainerConfig()
ContainerConfig.Name = "New container name"
ContainerConfig.Description = "Description of the new container (optional)"
ResultContainerConfig = IronBoxRESTObj.CreateEntitySFTContainer(Context, ContainerConfig)
if ResultContainerConfig is None:
print "Unable to create container"
return

print "New container created with ID=%s" % ResultContainerConfig.ContainerID

#--------------------------------------------------
# Remove the container
#--------------------------------------------------
if IronBoxRESTObj.RemoveEntityContainer(ResultContainerConfig.ContainerID) is False:
print "Unable to remove container"
return

print "New container was successfully removed"

#---------------------------------------------------
import string, datetime

# --------------------------------------------------
# Create an instance of the IronBox REST class
# --------------------------------------------------
IronBoxRESTObj = IronBoxRESTClient(
ironbox_email, ironbox_pwd, version=ironbox_api_version, verbose=True
)

# --------------------------------------------------
# Create the container, duplicate container names
# are supported
# --------------------------------------------------
container_config = IronBoxSFTContainerConfig()
container_config.Name = "New container name"
container_config.Description = "Description of the new container (optional)"
result_cont_conf = IronBoxRESTObj.create_entity_sft_cont(context, container_config)
if result_cont_conf is None:
print("Unable to create container")
return

print(f"New container created with ID={result_cont_conf.container_id}")

# Remove the container
if IronBoxRESTObj.remove_entity_container(result_cont_conf.container_id) is False:
print("Unable to remove container")
return

print("New container was successfully removed")


if __name__ == "__main__":
main()
84 changes: 43 additions & 41 deletions IronBoxDownloadReadyFiles.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/usr/bin/python
#---------------------------------------------------
#
# Demonstrates how to download blobs in an IronBox
# container that are in a ready state.
#
# Written by KevinLam@goironbox.com
# Website: www.goironbox.com
#
# Usage:
# python IronBoxDownloadReadyFiles.py
#
#---------------------------------------------------
import sys
from IronBoxREST import IronBoxRESTClient
from os.path import join

#---------------------------------------------------
"""
Demonstrates how to download blobs in an IronBox
container that are in a ready state.

Written by KevinLam@goironbox.com
Modified by motorific@gmail.com
Website: www.goironbox.com


Usage:
python IronBoxDownloadReadyFiles.py
"""


from IronBoxREST import IronBoxRESTClient
from os.path import join

# ---------------------------------------------------
# Your IronBox authentication parameters, you could
# also pass these in as command arguments
#---------------------------------------------------
ContainerID = 100777
IronBoxEmail = "email@email.com"
IronBoxPassword = "password"
IronBoxAPIServerURL = "https://api.goironcloud.com/latest/"
IronBoxAPIVersion = "latest"
# ---------------------------------------------------
container_id = 100777
ironbox_email = "email@email.com"
ironbox_pwd = "password"
ironbox_api_url = "https://api.goironcloud.com/latest/"
ironbox_api_version = "latest"

# Gets all the blobs in the Ready state (2). Other states:
# 0 = Blob created
Expand All @@ -32,29 +32,31 @@
# 3 = Checked out
# 4 = Entity is modifying
# 5 = None
BlobState = 2
blob_state = 2
output_dir = "./"

OutputDir = "./"

#---------------------------------------------------
# Main
#---------------------------------------------------
def main():

# Create an instance of the IronBox REST class
IronBoxRESTObj = IronBoxRESTClient(IronBoxEmail, IronBoxPassword, version=IronBoxAPIVersion, verbose=True)
IronBoxRESTObj = IronBoxRESTClient(
ironbox_email, ironbox_pwd, version=ironbox_api_version, verbose=True
)

# Get all the blobs in a ready state, result is a tuple list
# where 0 = blob ID and 1 = blob name
result = IronBoxRESTObj.GetContainerBlobInfoListByState(ContainerID, BlobState)
# where 0 = blob ID and 1 = blob name
result = IronBoxRESTObj.get_cont_blob_info_by_state(container_id, blob_state)
for item in result:
# Download and save the file locally
DestFilePath = join(OutputDir,item[1])
if IronBoxRESTObj.DownloadBlobFromContainer(ContainerID,item[0],DestFilePath) is True:
# Optionally you can delete the blob after download
#IronBoxRESTObj.RemoveEntityContainerBlob(ContainerID,item[0])
pass

#---------------------------------------------------

# Download and save the file locally
dest_file_path = join(output_dir, item[1])
if IronBoxRESTObj.download_blob_from_container(
container_id, item[0], dest_file_path
):
# Optionally you can delete the blob after download
# IronBoxRESTObj.RemoveEntityContainerBlob(ContainerID,item[0])
pass


if __name__ == "__main__":
main()
70 changes: 33 additions & 37 deletions IronBoxGetBlobInfoListByState.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
#!/usr/bin/python
#---------------------------------------------------
#
# Demonstrates how to retrieve the ID and names of
# each blob in an IronBox container by the given
# state.
#
# Written by KevinLam@goironbox.com
# Website: www.goironbox.com
#
# Usage:
# python IronBoxGetBlobInfoListByState.py
#
#---------------------------------------------------
import sys
from os import listdir
from os.path import isfile, join
from IronBoxREST import IronBoxRESTClient

#---------------------------------------------------
"""
Demonstrates how to retrieve the ID and names of
each blob in an IronBox container by the given
state.

Written by KevinLam@goironbox.com
Modified by motorific@gmail.com
Website: www.goironbox.com

Usage:
python IronBoxGetBlobInfoListByState.py
"""


from IronBoxREST import IronBoxRESTClient

# ---------------------------------------------------
# Your IronBox authentication parameters, you could
# also pass these in as command arguments
#---------------------------------------------------
ContainerID = 100777
IronBoxEmail = "email@email.com"
IronBoxPassword = "password"
IronBoxAPIServerURL = "https://api.goironcloud.com/latest/"
IronBoxAPIVersion = "latest"
# ---------------------------------------------------
container_id = 100777
ironbox_email = "email@email.com"
ironbox_pwd = "password"
ironbox_api_url = "https://api.goironcloud.com/latest/"
ironbox_api_version = "latest"

# Gets all the blobs in the Ready state (2). Other states:
# 0 = Blob created
Expand All @@ -34,23 +31,22 @@
# 3 = Checked out
# 4 = Entity is modifying
# 5 = None
BlobState = 2
blob_state = 2


#---------------------------------------------------
# Main
#---------------------------------------------------
def main():

# Create an instance of the IronBox REST class
IronBoxRESTObj = IronBoxRESTClient(IronBoxEmail, IronBoxPassword, version=IronBoxAPIVersion, verbose=True)
IronBoxRESTObj = IronBoxRESTClient(
ironbox_email, ironbox_pwd, version=ironbox_api_version, verbose=True
)


# Get all the blobs in a ready state, result is a tuple list
# where 0 = blob ID and 1 = blob name
result = IronBoxRESTObj.GetContainerBlobInfoListByState(ContainerID, BlobState)
# where 0 = blob ID and 1 = blob name
result = IronBoxRESTObj.get_cont_blob_info_by_state(container_id, blob_state)
for item in result:
print "%s -> %s" % (item[0],item[1])
print(f"{item[0]} -> {item[1]}")


#---------------------------------------------------
if __name__ == "__main__":
main()
Loading