com.microsoft.azure.storage.blob.BlobContainerPublicAccessType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-storage Show documentation
Show all versions of azure-storage Show documentation
SDK for Microsoft Azure Storage Clients
/**
* Copyright Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.azure.storage.blob;
import java.util.Locale;
import com.microsoft.azure.storage.core.SR;
import com.microsoft.azure.storage.core.Utility;
/**
* Specifies the level of public access that is allowed on the container.
*
* The public access setting indicates whether the container and its blobs can be read via an anonymous request.
*
* The {@link BlobContainerPublicAccessType} enumeration provides three levels of anonymous read access:
*
* - {@link BlobContainerPublicAccessType#OFF}, which prevents anonymous access.
* - {@link BlobContainerPublicAccessType#BLOB}, which permits anonymous read access to blob resources, but not to
* container metadata or to the list of blobs in the container.
* - {@link BlobContainerPublicAccessType#CONTAINER}, which permits anonymous read access to blob resources, container
* metadata, and the list of blobs in the container.
*
* For more information on managing anonymous access to Blob service resources, see Setting Access Control for Containers.
*/
public enum BlobContainerPublicAccessType {
/**
* Specifies blob-level public access. Clients can read the content and metadata of blobs within this container, but
* cannot read container metadata or list the blobs within the container.
*/
BLOB,
/**
* Specifies container-level public access. Clients can read blob content and metadata and container metadata, and
* can list the blobs within the container.
**/
CONTAINER,
/**
* Specifies no public access. Only the account owner can access resources in this container.
*/
OFF,
/**
* Specifies that the public access type is unknown.
*/
UNKNOWN;
/**
* Parses a public access level from the specified string.
*
* @param typeString
* A String
which contains the public access level
* to parse.
*
* @return A BlobContainerPublicAccessType
value that
* represents the public access level for the container.
*/
protected static BlobContainerPublicAccessType parse(final String typeString) {
if (Utility.isNullOrEmpty(typeString)) {
return OFF;
}
else if (SR.BLOB.equals(typeString.toLowerCase(Locale.US))) {
return BLOB;
}
else if (SR.CONTAINER.equals(typeString.toLowerCase(Locale.US))) {
return CONTAINER;
}
else {
return UNKNOWN;
}
}
}