use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method getTables.
@NotNull
public List<Table> getTables(@NotNull StorageAccount storageAccount) throws AzureCmdException {
List<Table> tList = new ArrayList<Table>();
try {
CloudTableClient client = getCloudTableClient(storageAccount);
for (String tableName : client.listTables()) {
CloudTable cloudTable = client.getTableReference(tableName);
String uri = cloudTable.getUri() != null ? cloudTable.getUri().toString() : "";
tList.add(new Table(tableName, uri));
}
return tList;
} catch (Throwable t) {
throw new AzureCmdException("Error retrieving the Table list", t);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method createTableEntity.
@NotNull
public TableEntity createTableEntity(@NotNull StorageAccount storageAccount, @NotNull String tableName, @NotNull String partitionKey, @NotNull String rowKey, @NotNull Map<String, Property> properties) throws AzureCmdException {
try {
CloudTableClient client = getCloudTableClient(storageAccount);
CloudTable cloudTable = client.getTableReference(tableName);
DynamicTableEntity entity = getDynamicTableEntity(partitionKey, rowKey, properties);
TableRequestOptions tro = new TableRequestOptions();
tro.setTablePayloadFormat(TablePayloadFormat.JsonFullMetadata);
TableResult result = cloudTable.execute(TableOperation.insert(entity, true), tro, null);
DynamicTableEntity resultEntity = result.getResultAsType();
return getTableEntity(tableName, resultEntity);
} catch (Throwable t) {
throw new AzureCmdException("Error creating the Table Entity", t);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method getRootDirectory.
@NotNull
public BlobDirectory getRootDirectory(@NotNull String connectionString, @NotNull BlobContainer blobContainer) throws AzureCmdException {
try {
CloudBlobClient client = getCloudBlobClient(connectionString);
CloudBlobContainer container = client.getContainerReference(blobContainer.getName());
CloudBlobDirectory directory = container.getDirectoryReference("");
String uri = directory.getUri() != null ? directory.getUri().toString() : "";
return new BlobDirectory("", uri, blobContainer.getName(), "");
} catch (Throwable t) {
throw new AzureCmdException("Error retrieving the root Blob Directory", t);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method deleteBlobFile.
public void deleteBlobFile(@NotNull String connectionString, @NotNull BlobFile blobFile) throws AzureCmdException {
try {
CloudBlobClient client = getCloudBlobClient(connectionString);
String containerName = blobFile.getContainerName();
CloudBlobContainer container = client.getContainerReference(containerName);
CloudBlob blob = getCloudBlob(container, blobFile);
blob.deleteIfExists();
} catch (Throwable t) {
throw new AzureCmdException("Error deleting the Blob File", t);
}
}
use of com.microsoft.azuretools.azurecommons.helpers.AzureCmdException in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method downloadBlobFileContent.
public void downloadBlobFileContent(@NotNull String connectionString, @NotNull BlobFile blobFile, @NotNull OutputStream content) throws AzureCmdException {
try {
CloudBlobClient client = getCloudBlobClient(connectionString);
String containerName = blobFile.getContainerName();
CloudBlobContainer container = client.getContainerReference(containerName);
CloudBlob blob = getCloudBlob(container, blobFile);
blob.download(content);
} catch (Throwable t) {
throw new AzureCmdException("Error downloading the Blob File content", t);
}
}
Aggregations