Search in sources :

Example 1 with ServiceProperties

use of com.microsoft.azure.storage.ServiceProperties in project cyberduck by iterate-ch.

the class AzureLoggingFeature method getConfiguration.

@Override
public LoggingConfiguration getConfiguration(final Path container) throws BackgroundException {
    try {
        final ServiceProperties properties = session.getClient().downloadServiceProperties(null, context);
        final LoggingConfiguration configuration = new LoggingConfiguration(!properties.getLogging().getLogOperationTypes().isEmpty(), "$logs");
        // When you have configured Storage Logging to log request data from your storage account, it saves the log data
        // to blobs in a container named $logs in your storage account.
        configuration.setContainers(Collections.singletonList(new Path("/$logs", EnumSet.of(Path.Type.volume, Path.Type.directory))));
        return configuration;
    } catch (StorageException e) {
        throw new AzureExceptionMappingService().map("Cannot read container configuration", e);
    }
}
Also used : Path(ch.cyberduck.core.Path) ServiceProperties(com.microsoft.azure.storage.ServiceProperties) LoggingConfiguration(ch.cyberduck.core.logging.LoggingConfiguration) StorageException(com.microsoft.azure.storage.StorageException)

Example 2 with ServiceProperties

use of com.microsoft.azure.storage.ServiceProperties in project cyberduck by iterate-ch.

the class AzureLoggingFeature method setConfiguration.

@Override
public void setConfiguration(final Path container, final LoggingConfiguration configuration) throws BackgroundException {
    try {
        final ServiceProperties properties = session.getClient().downloadServiceProperties(null, context);
        final LoggingProperties l = new LoggingProperties();
        if (configuration.isEnabled()) {
            l.setLogOperationTypes(EnumSet.allOf(LoggingOperations.class));
        } else {
            l.setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class));
        }
        properties.setLogging(l);
        session.getClient().uploadServiceProperties(properties, null, context);
    } catch (StorageException e) {
        throw new AzureExceptionMappingService().map("Failure to write attributes of {0}", e, container);
    }
}
Also used : ServiceProperties(com.microsoft.azure.storage.ServiceProperties) LoggingOperations(com.microsoft.azure.storage.LoggingOperations) LoggingProperties(com.microsoft.azure.storage.LoggingProperties) StorageException(com.microsoft.azure.storage.StorageException)

Aggregations

ServiceProperties (com.microsoft.azure.storage.ServiceProperties)2 StorageException (com.microsoft.azure.storage.StorageException)2 Path (ch.cyberduck.core.Path)1 LoggingConfiguration (ch.cyberduck.core.logging.LoggingConfiguration)1 LoggingOperations (com.microsoft.azure.storage.LoggingOperations)1 LoggingProperties (com.microsoft.azure.storage.LoggingProperties)1