com.microsoft.azure.storage.ServiceProperties Java Examples
The following examples show how to use
com.microsoft.azure.storage.ServiceProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AzureLoggingFeature.java From cyberduck with GNU General Public License v3.0 | 6 votes |
@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); } }
Example #2
Source File: AzureLoggingFeature.java From cyberduck with GNU General Public License v3.0 | 6 votes |
@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); } }
Example #3
Source File: QueryMetricsAndActivityLogs.java From azure-libraries-for-java with MIT License | 4 votes |
private static void addBlobTransactions(String storageConnectionString) throws IOException, URISyntaxException, InvalidKeyException, StorageException { // Get the script to upload // InputStream scriptFileAsStream = QueryMetricsAndActivityLogs .class .getResourceAsStream("/install_apache.sh"); // Get the size of the stream // int fileSize; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte[] buffer = new byte[256]; int bytesRead; while ((bytesRead = scriptFileAsStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } fileSize = outputStream.size(); outputStream.close(); // Upload the script file as block blob // CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString); CloudBlobClient cloudBlobClient = account.createCloudBlobClient(); CloudBlobContainer container = cloudBlobClient.getContainerReference("scripts"); container.createIfNotExists(); ServiceProperties serviceProps = cloudBlobClient.downloadServiceProperties(); // configure Storage logging and metrics LoggingProperties logProps = new LoggingProperties(); logProps.setLogOperationTypes(EnumSet.of(LoggingOperations.READ, LoggingOperations.WRITE)); logProps.setRetentionIntervalInDays(2); logProps.setVersion("1.0"); serviceProps.setLogging(logProps); MetricsProperties metricProps = new MetricsProperties(); metricProps.setMetricsLevel(MetricsLevel.SERVICE_AND_API); metricProps.setRetentionIntervalInDays(2); metricProps.setVersion("1.0"); serviceProps.setHourMetrics(metricProps); serviceProps.setMinuteMetrics(metricProps); // Set the default service version to be used for anonymous requests. serviceProps.setDefaultServiceVersion("2015-04-05"); // Set the service properties. cloudBlobClient.uploadServiceProperties(serviceProps); CloudBlockBlob blob = container.getBlockBlobReference("install_apache.sh"); blob.upload(scriptFileAsStream, fileSize); // give sometime for the infrastructure to process the records and fit into time grain. SdkContext.sleep(6 * 60000); }
Example #4
Source File: FileServiceProperties.java From azure-storage-android with Apache License 2.0 | 4 votes |
/** * Generate a <code>FileServiceProperties</code> from a new <code>ServiceProperties</code>. */ public FileServiceProperties() { this(new ServiceProperties()); }
Example #5
Source File: CloudBlobClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Retrieves the current {@link ServiceProperties} for the given storage service. This includes Logging, * HourMetrics, MinuteMetrics and CORS configurations. * * @return A {@link ServiceProperties} object representing the current configuration of the service. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final ServiceProperties downloadServiceProperties() throws StorageException { return this.downloadServiceProperties(null /* options */, null /* opContext */); }
Example #6
Source File: CloudBlobClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Uploads a new {@link ServiceProperties} configuration to the given storage service. This includes Logging, * HourMetrics, MinuteMetrics and CORS configurations. * * @param properties * A {@link ServiceProperties} object which specifies the service properties to upload. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { this.uploadServiceProperties(properties, null /* options */, null /* opContext */); }
Example #7
Source File: FileServiceProperties.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Generate a <code>FileServiceProperties</code> from the given <code>ServiceProperties</code>. * * @param properties * The <code>ServiceProperties</code> to use */ FileServiceProperties(ServiceProperties properties) { this.serviceProperties = properties; this.serviceProperties.setLogging(null); this.serviceProperties.setDefaultServiceVersion(null); }
Example #8
Source File: FileServiceProperties.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Gets the <code>ServiceProperties</code> for use by the service. * * @return The <code>ServiceProperties</code> */ ServiceProperties getServiceProperties() { return this.serviceProperties; }
Example #9
Source File: CloudTableClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Retrieves the current {@link ServiceProperties} for the given storage service. This includes Logging, * HourMetrics, MinuteMetrics and CORS configurations. * * @return the {@link ServiceProperties} object representing the current configuration of the service. * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final ServiceProperties downloadServiceProperties() throws StorageException { return this.downloadServiceProperties(null /* options */, null /* opContext */); }
Example #10
Source File: CloudTableClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Uploads a new {@link ServiceProperties} configuration to the given storage service. This includes Logging, * HourMetrics, MinuteMetrics and CORS configurations. * * @param properties * The {@link ServiceProperties} to upload. * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { this.uploadServiceProperties(properties, null /* options */, null /* opContext */); }
Example #11
Source File: CloudQueueClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Retrieves the current {@link ServiceProperties} for the given storage service. This includes Logging, * HourMetrics, MinuteMetrics and CORS configurations. * * @return the {@link ServiceProperties} object representing the current configuration of the service. * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final ServiceProperties downloadServiceProperties() throws StorageException { return this.downloadServiceProperties(null /* options */, null /* opContext */); }
Example #12
Source File: CloudQueueClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Uploads a new {@link ServiceProperties} configuration to the given storage service. This includes Logging, * HourMetrics, MinuteMetrics and CORS configurations. * * @param properties * The {@link ServiceProperties} to upload. * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { this.uploadServiceProperties(properties, null /* options */, null /* opContext */); }