CloudFileShare Class
- java.
lang. Object - com.
microsoft. azure. storage. file. CloudFileShare
- com.
public class CloudFileShare
Represents a share in the Microsoft Azure File service.
Shares hold directories, which are encapsulated as CloudFileDirectory objects, and directories hold files. Directories can also contain sub-directories.
Constructor Summary
Constructor | Description |
---|---|
CloudFileShare(final StorageUri storageUri) |
Creates an instance of the class using the specified URI. |
CloudFileShare(final StorageUri storageUri, final StorageCredentials credentials) |
Creates an instance of the class using the specified StorageUri and credentials. |
CloudFileShare(final String shareName, String snapshotID, final CloudFileClient client) |
Creates an instance of the class using the specified name and client. |
CloudFileShare(final URI uri) |
Creates an instance of the class using the specified URI. |
CloudFileShare(final URI uri, final StorageCredentials credentials) |
Creates an instance of the class using the specified URI and credentials. |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
assertNoSnapshot()
Asserts that the share is not a snapshot. |
void |
create()
Creates the share. |
void |
create(FileRequestOptions options, OperationContext opContext)
Creates the share using the specified options and operation context. |
String |
createFilePermission(String permission)
Creates a file permission. |
String |
createFilePermission(String permission, FileRequestOptions options, OperationContext opContext)
Creates a file permission. |
boolean |
createIfNotExists()
Creates the share if it does not exist. |
boolean |
createIfNotExists(FileRequestOptions options, OperationContext opContext)
Creates the share if it does not exist, using the specified request options and operation context. |
final Cloud |
createSnapshot()
Creates a snapshot of the share. |
final Cloud |
createSnapshot(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Creates a snapshot of the file share using the specified request options and operation context. |
final Cloud |
createSnapshot(final HashMap<String, String> metadata, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Creates a snapshot of the file share using the specified request options and operation context. |
void |
delete()
Deletes the share. |
void |
delete(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share using the specified request options and operation context. |
void |
delete(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share using the specified snapshot and request options, and operation context. A share that has snapshots cannot be deleted unless the snapshots are also deleted. If a share has snapshots, use the INCLUDE_SNAPSHOTS value in the parameter to include the snapshots when deleting the base share. |
boolean |
deleteIfExists()
Deletes the share if it exists. |
boolean |
deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share if it exists using the specified request options and operation context. |
boolean |
deleteIfExists(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share if it exists, using the specified snapshot and request options, and operation context. A share that has snapshots cannot be deleted unless the snapshots are also deleted. If a share has snapshots, use the INCLUDE_SNAPSHOTS value in the parameter to include the snapshots when deleting the base share. |
void |
downloadAttributes()
Downloads the share's attributes, which consist of metadata and properties. |
void |
downloadAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads the share's attributes, which consist of metadata and properties, using the specified request options and operation context. |
File |
downloadPermissions()
Downloads the permission settings for the share. |
File |
downloadPermissions(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads the permissions settings for the share using the specified request options and operation context. |
boolean |
exists()
Returns a value that indicates whether the share exists. |
boolean |
exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Returns a value that indicates whether the share exists, using the specified request options and operation context. |
String |
generateSharedAccessSignature(final SharedAccessFilePolicy policy, final String groupPolicyIdentifier)
Returns a shared access signature for the share. Note this does not contain the leading "?". |
String |
generateSharedAccessSignature(final SharedAccessFilePolicy policy, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)
Returns a shared access signature for the share. Note this does not contain the leading "?". |
String |
getFilePermission(String filePermissionKey)
Gets the file permission associated with a file permission key. |
String |
getFilePermission(String filePermissionKey, FileRequestOptions options, OperationContext opContext)
Gets the file permission associated with a file permission key. |
HashMap<String, String> |
getMetadata()
Returns the metadata for the share. This value is initialized with the metadata from the share by a call to downloadAttributes(), and is set on the share with a call to uploadMetadata(). |
String |
getName()
Returns the name of the share. |
File |
getProperties()
Returns the properties for the share. |
final URI |
getQualifiedUri()
Returns the snapshot or shared access signature qualified URI for this share. |
Cloud |
getRootDirectoryReference()
Returns a reference to a CloudFileDirectory object that represents the root file directory within this share. |
Cloud |
getServiceClient()
Returns the File service client associated with this share. |
final String |
getSnapshot()
Returns the snapshotID for this share. |
Share |
getStats()
Queries the service for this share's ShareStats. |
Share |
getStats(FileRequestOptions options, OperationContext opContext)
Queries the service for this share's ShareStats. |
Storage |
getStorageUri()
Returns the list of URIs for all locations. |
URI |
getUri()
Returns the URI for this share. |
final boolean |
isSnapshot()
Indicates whether this share is a snapshot. |
void |
setMetadata(final HashMap<String, String> metadata)
Sets the metadata collection of name-value pairs to be set on the share with an uploadMetadata() call. This collection will overwrite any existing share metadata. If this is set to an empty collection, the share metadata will be cleared on an uploadMetadata() call. |
void |
setProperties(final FileShareProperties properties)
Sets the properties for the share. |
void |
uploadMetadata()
Uploads the share's metadata. |
void |
uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the share's metadata using the specified request options and operation context. |
void |
uploadPermissions(final FileSharePermissions permissions)
Uploads the share's permissions. |
void |
uploadPermissions(final FileSharePermissions permissions, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the share's permissions using the specified request options and operation context. |
final void |
uploadProperties()
Updates the share's properties on the storage service. Use downloadAttributes() to retrieve the latest values for the share's properties and metadata from the Microsoft Azure storage service. |
final void |
uploadProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Updates the share's properties using the request options, and operation context. Use downloadAttributes() to retrieve the latest values for the share's properties and metadata from the Microsoft Azure storage service. |
Constructor Details
CloudFileShare
public CloudFileShare(final StorageUri storageUri)
Creates an instance of the class using the specified URI.
Parameters:
Throws:
CloudFileShare
public CloudFileShare(final StorageUri storageUri, final StorageCredentials credentials)
Creates an instance of the class using the specified StorageUri and credentials.
Parameters:
Throws:
CloudFileShare
public CloudFileShare(final String shareName, String snapshotID, final CloudFileClient client)
Creates an instance of the class using the specified name and client.
Parameters:
String
which represents the name of the share, which must adhere to share naming rules. The share name should not include any path separator characters (/). Share names must be lowercase, between 3-63 characters long and must start with a letter or number. Share names may contain only letters, numbers, and the dash (-) character.
String
that represents the snapshot version, if applicable.
Throws:
CloudFileShare
public CloudFileShare(final URI uri)
Creates an instance of the class using the specified URI.
Parameters:
java.net.URI
object that represents the absolute URI of the share.
Throws:
CloudFileShare
public CloudFileShare(final URI uri, final StorageCredentials credentials)
Creates an instance of the class using the specified URI and credentials.
Parameters:
java.net.URI
object that represents the absolute URI of the share.
Throws:
Method Details
assertNoSnapshot
protected void assertNoSnapshot()
Asserts that the share is not a snapshot.
create
public void create()
Creates the share.
Throws:
create
public void create(FileRequestOptions options, OperationContext opContext)
Creates the share using the specified options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
createFilePermission
public String createFilePermission(String permission)
Creates a file permission.
Parameters:
String
object that represents the file permission to create.
Returns:
String
representing the file permission key associated with the file permission created.Throws:
createFilePermission
public String createFilePermission(String permission, FileRequestOptions options, OperationContext opContext)
Creates a file permission.
Parameters:
String
object that represents the file permission to create.
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
String
representing the file permission key associated with the file permission created.Throws:
createIfNotExists
public boolean createIfNotExists()
Creates the share if it does not exist.
Returns:
true
if the share did not already exist and was created; otherwise, false
.
Throws:
createIfNotExists
public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext)
Creates the share if it does not exist, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client (CloudFileClient).
Returns:
true
if the share did not already exist and was created; otherwise, false
.
Throws:
createSnapshot
public final CloudFileShare createSnapshot()
Creates a snapshot of the share.
Returns:
CloudFileShare
object that represents the snapshot of the share.Throws:
createSnapshot
public final CloudFileShare createSnapshot(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Creates a snapshot of the file share using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
CloudFileShare
object that represents the snapshot of the file share.Throws:
createSnapshot
public final CloudFileShare createSnapshot(final HashMap
Creates a snapshot of the file share using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
CloudFileShare
object that represents the snapshot of the file share.Throws:
delete
public void delete()
Deletes the share.
Throws:
delete
public void delete(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
delete
public void delete(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share using the specified snapshot and request options, and operation context.
A share that has snapshots cannot be deleted unless the snapshots are also deleted. If a share has snapshots, use the INCLUDE_SNAPSHOTS value in the parameter to include the snapshots when deleting the base share.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
deleteIfExists
public boolean deleteIfExists()
Deletes the share if it exists.
Returns:
true
if the share existed and was deleted; otherwise, false
.
Throws:
deleteIfExists
public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share if it exists using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the share existed and was deleted; otherwise, false
.
Throws:
deleteIfExists
public boolean deleteIfExists(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the share if it exists, using the specified snapshot and request options, and operation context.
A share that has snapshots cannot be deleted unless the snapshots are also deleted. If a share has snapshots, use the INCLUDE_SNAPSHOTS value in the parameter to include the snapshots when deleting the base share.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the share existed and was deleted; otherwise, false
.
Throws:
downloadAttributes
public void downloadAttributes()
Downloads the share's attributes, which consist of metadata and properties.
Throws:
downloadAttributes
public void downloadAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads the share's attributes, which consist of metadata and properties, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
downloadPermissions
public FileSharePermissions downloadPermissions()
Downloads the permission settings for the share.
Returns:
Throws:
downloadPermissions
public FileSharePermissions downloadPermissions(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads the permissions settings for the share using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
exists
public boolean exists()
Returns a value that indicates whether the share exists.
Returns:
true
if the share exists, otherwise false
.
Throws:
exists
public boolean exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Returns a value that indicates whether the share exists, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the share exists, otherwise false
.
Throws:
generateSharedAccessSignature
public String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final String groupPolicyIdentifier)
Returns a shared access signature for the share. Note this does not contain the leading "?".
Parameters:
String
which represents the share-level access policy.
Returns:
String
which represents a shared access signature for the share.Throws:
generateSharedAccessSignature
public String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)
Returns a shared access signature for the share. Note this does not contain the leading "?".
Parameters:
String
which represents the share-level access policy.
Returns:
String
which represents a shared access signature for the share.Throws:
getFilePermission
public String getFilePermission(String filePermissionKey)
Gets the file permission associated with a file permission key.
Parameters:
String
object that represents the file permission key.
Returns:
String
representing the file permission associated with the file permission key.Throws:
getFilePermission
public String getFilePermission(String filePermissionKey, FileRequestOptions options, OperationContext opContext)
Gets the file permission associated with a file permission key.
Parameters:
String
object that represents the file permission key.
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
String
representing the file permission associated with the file permission key.Throws:
getMetadata
public HashMap
Returns the metadata for the share. This value is initialized with the metadata from the share by a call to downloadAttributes(), and is set on the share with a call to uploadMetadata().
Returns:
java.util.HashMap
object that represents the metadata for the share.getName
public String getName()
Returns the name of the share.
Returns:
String
that represents the name of the share.getProperties
public FileShareProperties getProperties()
Returns the properties for the share.
Returns:
getQualifiedUri
public final URI getQualifiedUri()
Returns the snapshot or shared access signature qualified URI for this share.
Returns:
java.net.URI
object that represents the snapshot or shared access signature.Throws:
getRootDirectoryReference
public CloudFileDirectory getRootDirectoryReference()
Returns a reference to a CloudFileDirectory object that represents the root file directory within this share.
Returns:
Throws:
getServiceClient
public CloudFileClient getServiceClient()
Returns the File service client associated with this share.
Returns:
getSnapshot
public final String getSnapshot()
Returns the snapshotID for this share.
Returns:
getStats
public ShareStats getStats()
Queries the service for this share's ShareStats.
Returns:
Throws:
getStats
public ShareStats getStats(FileRequestOptions options, OperationContext opContext)
Queries the service for this share's ShareStats.
Parameters:
null
will use the default request options from the associated service client (CloudFileClient).
Returns:
Throws:
getStorageUri
public StorageUri getStorageUri()
Returns the list of URIs for all locations.
Returns:
getUri
public URI getUri()
Returns the URI for this share.
Returns:
isSnapshot
public final boolean isSnapshot()
Indicates whether this share is a snapshot.
Returns:
true
if the share is a snapshot, otherwise false
.
setMetadata
public void setMetadata(final HashMap
Sets the metadata collection of name-value pairs to be set on the share with an uploadMetadata() call. This collection will overwrite any existing share metadata. If this is set to an empty collection, the share metadata will be cleared on an uploadMetadata() call.
Parameters:
java.util.HashMap
object that represents the metadata being assigned to the share.
setProperties
public void setProperties(final FileShareProperties properties)
Sets the properties for the share.
Parameters:
uploadMetadata
public void uploadMetadata()
Uploads the share's metadata.
Throws:
uploadMetadata
public void uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the share's metadata using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
uploadPermissions
public void uploadPermissions(final FileSharePermissions permissions)
Uploads the share's permissions.
Parameters:
Throws:
uploadPermissions
public void uploadPermissions(final FileSharePermissions permissions, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the share's permissions using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
uploadProperties
public final void uploadProperties()
Updates the share's properties on the storage service.
Use downloadAttributes() to retrieve the latest values for the share's properties and metadata from the Microsoft Azure storage service.
Throws:
uploadProperties
public final void uploadProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Updates the share's properties using the request options, and operation context.
Use downloadAttributes() to retrieve the latest values for the share's properties and metadata from the Microsoft Azure storage service.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
Applies to
Azure SDK for Java