Skip to content

Commit f68d5c6

Browse files
committed
Release v0.2.0
1 parent 100c641 commit f68d5c6

File tree

35 files changed

+1438
-277
lines changed

35 files changed

+1438
-277
lines changed

Documentation/APIReference.md

Lines changed: 356 additions & 88 deletions
Large diffs are not rendered by default.

Documentation/Blob.md

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ results = containerClient.listBlobs;
251251
% Display the name of the 1st blob assuming the container is not empty
252252
results(1).getName()
253253
```
254+
See also [Advanced listing support](#advanced-listing-support) below.
254255

255256
#### Create a BlobClient
256257

@@ -458,4 +459,151 @@ blobClient.uploadFromFile('myfile.txt','overwrite',true,'leaseId',leaseId);
458459
blobClient.deleteBlob('leaseId',leaseId);
459460
```
460461

461-
[//]: # (Copyright 2020-2022 The MathWorks, Inc.)
462+
### Advanced listing support
463+
464+
A basic listing of a container's contents can be done as follows:
465+
466+
```matlab
467+
% Get a blob name and create a client using it
468+
results = containerClient.listBlobs;
469+
% Assume there is a blob with name:
470+
results(1).getName();
471+
```
472+
473+
This returns an array of BlobItems in a container, with folder structures flattened. The Java PagedIterable is consumed by the MATLAB `listBlobs` methods, while convenient this makes the method unsuitable for use with containers with very large numbers of blobs. Blob names are returned in lexicographic order.
474+
475+
The `BlobItem.isPrefix` method can be used to determine if an entry is a directory or not.
476+
477+
It is sometimes necessary to provide a more advanced query. This can be done using the following additions:
478+
479+
* A directory name prefix
480+
* An `azure.storage.blob.models.BlobListDetails` object
481+
* An `azure.storage.blob.models.ListBlobsOptions` object
482+
483+
#### Using a prefix/directory
484+
485+
`BlobContainerClient.listBlobsByHierarchy(directory)` Returns all the blobs and directories (prefixes) under the given directory (prefix). Directories will have `BlobItem.isPrefix()` set to true. Blob names are returned in lexicographic order. E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the root level 'bar', will return the following results when prefix/directory is not set.
486+
487+
* foo/ (isPrefix = true)
488+
* bar (isPrefix = false)
489+
490+
And will return the following results when prefix="foo/":
491+
492+
* foo/foo1 (isPrefix = false)
493+
* foo/foo2 (isPrefix = false)
494+
495+
Alternatively the following arguments can be provided `BlobContainerClient.listBlobsByHierarchy(delimiter, options, timeout)`:
496+
497+
* delimiter - The delimiter for blob hierarchy, "/" for hierarchy based on directories. "/" should be used in almost all circumstances.
498+
* options - `ListBlobsOptions`, see below.
499+
* timeout - A number of seconds timeout value beyond which a runtime exception will be raised.
500+
501+
#### ListBlobsOptions
502+
503+
A `ListBlobsOptions` object allows the following criteria to be set:
504+
505+
* `setDetails(blobListDetails)` further options see below.
506+
* `setMaxResultsPerPage(maxResultsPerPage)` Specifies the maximum number of blobs to return, including all BlobPrefix elements. In practice the list methods consume the iterators, so unless working directly with the Java Handle methods this should be ignored.
507+
* `setPrefix(prefix)` Filters the results to return only blobs whose names begin with the specified prefix.
508+
509+
`set` methods return an updated `ListBlobsOptions` object. `get` methods are also provided.
510+
511+
#### BlobListDetails
512+
513+
Allows specifying of additional information to be returned with each blob when listing blobs in a container (via a BlobContainerClient object). This type is immutable to ensure thread-safety of requests, so changing the details for a different listing operation requires construction of a new object.
514+
515+
`get` methods return logicals and `set` methods return an updated `BlobListDetails` object.
516+
517+
* `getRetrieveCopy()` Whether blob metadata related to any current or previous Copy Blob operation should be included in the response.
518+
* `getRetrieveDeletedBlobs()` Whether blobs which have been soft deleted should be returned.
519+
* `getRetrieveDeletedBlobsWithVersions()` Whether blobs which have been deleted with versioning.
520+
* `getRetrieveImmutabilityPolicy()` Whether immutability policy for the blob should be returned.
521+
* `getRetrieveLegalHold()` Whether legal hold for the blob should be returned.
522+
* `getRetrieveMetadata()` Whether blob metadata should be returned.
523+
* `getRetrieveSnapshots()` Whether snapshots should be returned.
524+
* `getRetrieveTags()` Whether blob tags should be returned.
525+
* `getRetrieveUncommittedBlobs()` Whether blobs for which blocks have been uploaded, but which have not been committed using Put Block List, should be included in the response.
526+
* `getRetrieveVersions()` Whether versions should be returned.
527+
528+
### Blob properties & metadata
529+
530+
A blob's properties can be queried reason about the blob, e.g. check its MD5 or size.
531+
In this case the file/object is 0 bytes in size.
532+
533+
```matlabsession
534+
>> myBlob = l(1)
535+
myBlob =
536+
BlobItem with no properties.
537+
>> myProps = myBlob.getProperties;
538+
>> myProps.getContentMd5
539+
ans =
540+
'1B2M2Y8AsgTpgAmY7PhCfg=='
541+
>> myProps.getContentLength
542+
ans =
543+
int64
544+
0
545+
```
546+
547+
Use `methods()` on a properties object to explore the available data.
548+
549+
```{note}
550+
`properties` is a reserved word in MATLAB and should not be used as a variable name etc.
551+
```
552+
553+
In this case the blob has no available metadata, an empty containers.Map is returned:
554+
555+
```matlab
556+
% Create a Container client
557+
client = builder.buildClient();
558+
% Create a BlobListDetails to control what blob details are returned when listing
559+
b = azure.storage.blob.models.BlobListDetails();
560+
% Enable Metadata & Tags
561+
b = b.setRetrieveMetadata(true);
562+
b = b.setRetrieveTags(true);
563+
% Create a ListBlobsOptions to hold the BlobListDetails
564+
l = azure.storage.blob.models.ListBlobsOptions();
565+
lnew = l.setDetails(b);
566+
567+
% Return a list of blobs, "/" is teh delimiter and 60 is a timeout in seconds
568+
l = client.listBlobsByHierarchy("/", lnew, 60);
569+
570+
% Pick one of the returned blobs
571+
myBlob = l(1);
572+
% Get the Metadata
573+
md = myBlob.getMetadata
574+
md =
575+
Map with properties:
576+
Count: 1
577+
KeyType: char
578+
ValueType: char
579+
% Display the containers.Map content in this case a tag
580+
md.keys
581+
ans =
582+
1×1 cell array
583+
{'barMetadataKey'}
584+
K>> md.values
585+
ans =
586+
1×1 cell array
587+
{'barMetadataVal'}
588+
589+
% Get the tag directly and display the containers.Map content
590+
tags = myBlob.getTags
591+
tags =
592+
Map with properties:
593+
Count: 1
594+
KeyType: char
595+
ValueType: char
596+
tags.keys
597+
ans =
598+
1×1 cell array
599+
{'barMetadataKey'}
600+
tags.values
601+
ans =
602+
1×1 cell array
603+
{'barMetadataVal'}
604+
```
605+
606+
607+
For more information, see [https://azuresdkdocs.blob.core.windows.net/$web/java/azure-storage-blob/12.21.0/com/azure/storage/blob/BlobContainerClient.html#listBlobs()](https://azuresdkdocs.blob.core.windows.net/$web/java/azure-storage-blob/12.21.0/com/azure/storage/blob/BlobContainerClient.html#listBlobs())
608+
609+
[//]: # (Copyright 2020-2023 The MathWorks, Inc.)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Services it currently supports:
1919
2020
## Requirements
2121

22-
* [MathWorks®](https://www.mathworks.com) Products
22+
* [MathWorks®](http://www.mathworks.com) Products
2323
* MATLAB® release R2019a or later
2424
* (optional) MATLAB Compiler™ and Compiler SDK™
2525
* (optional) MATLAB Production Server™
@@ -28,7 +28,7 @@ Services it currently supports:
2828
* Maven™ 3.6.1 or later
2929
* JDK 8 or later
3030

31-
This package is primarily tested using Ubuntu™ 20.04 and Windows® 10.
31+
This package is primarily tested using Ubuntu™ 20.04 and Windows® 11.
3232

3333
## Documentation
3434

RELEASENOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Release Notes
44

5+
## Release 0.2.0 March 13th 2023
6+
7+
* Added additional blob listing support
8+
* Increase Azure SDK bom version to 1.2.10
9+
* Documentation update
10+
511
## Release 0.1.1 September 7th 2022
612

713
* Published documentation to GitHub pages.

Software/Java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>com.azure</groupId>
2424
<artifactId>azure-sdk-bom</artifactId>
25-
<version>1.2.5</version>
25+
<version>1.2.10</version>
2626
<type>pom</type>
2727
<scope>import</scope>
2828
</dependency>
Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
function client = createKeyVaultClient(varargin)
2-
% CREATEKEYVAULTCLIENT Convenience function for creating KeyClient and
3-
% SecretClient
4-
%
5-
% client = CREATEKEYVAULTCLIENT('Type','Key') creates a KeyClient with
6-
% default options.
7-
%
8-
% client = CREATEKEYVAULTCLIENT('Type','Secret') creates SecretClient with
9-
% default options.
10-
%
11-
% By default CREATEKEYVAULTCLIENT reads Credential information and the
12-
% Vault Name from a configuration file named 'keyvaultsettings.json'. The
13-
% function automatically searches for this file on the MATLABPATH. It is
14-
% possible to specify a different filename using 'ConfigurationFile'. It is
15-
% also possible to provide 'Credentials' and 'VaultName' as inputs to the
16-
% function directly in case which no configuration file may be needed. See
17-
% the Name, Value pairs below for more details.
18-
%
19-
% Additional Name, Value pairs can be supplied to configure non-default
20-
% options:
21-
%
22-
% 'ConfigurationFile', explicitly specify which configuration file to
23-
% use. This file is used for configuring Credentials (when not
24-
% supplied as input) and/or Account Name (when not supplied as input).
25-
%
26-
% Default Value: 'keyvaultsettings.json'
27-
%
28-
% 'Credentials', explicitly specify credentials to use. This for example
29-
% allows building multiple clients based on the same credentials
30-
% without having to go through (interactive) authentication again. If
31-
% not specified, CREATEKEYVAULTCLIENT uses configureCredentials with
32-
% 'ConfigurationFile' as input to first configure credentials before
33-
% building the client.
34-
%
35-
% Hint: configureCredentials can be used to build valid Credentials.
36-
%
37-
% Example:
38-
% credentials = configureCredentials('myCredentials.json');
39-
% client1 = CREATEKEYVAULTCLIENT('Credentials',credentials,'Type','Key')
40-
% client2 = CREATEKEYVAULTCLIENT('Credentials',credentials,'Type','Secret')
41-
%
42-
% 'VaultName', explicitly specify the Vault name for the client. If not
43-
% specified CREATEKEYVAULTCLIENT uses loadConfigurationSettings to
44-
% load configuration options from 'ConfigurationFile'. This file must
45-
% then contain a "VaultName" setting.
46-
%
47-
% See also CONFIGURECREDENTIALS, LOADCONFIGURATIONSETTINGS
2+
% CREATEKEYVAULTCLIENT Convenience function for creating KeyClient and
3+
% SecretClient
4+
%
5+
% client = createKeyVaultClient('Type','Key') creates a KeyClient with
6+
% default options.
7+
%
8+
% client = createKeyVaultClient('Type','Secret') creates SecretClient with
9+
% default options.
10+
%
11+
% By default createKeyVaultClient reads Credential information and the
12+
% Vault Name from a configuration file named 'keyvaultsettings.json'. The
13+
% function automatically searches for this file on the MATLABPATH. It is
14+
% possible to specify a different filename using 'ConfigurationFile'. It is
15+
% also possible to provide 'Credentials' and 'VaultName' as inputs to the
16+
% function directly in case which no configuration file may be needed. See
17+
% the Name, Value pairs below for more details.
18+
%
19+
% Additional Name, Value pairs can be supplied to configure non-default
20+
% options:
21+
%
22+
% 'ConfigurationFile', explicitly specify which configuration file to
23+
% use. This file is used for configuring Credentials (when not
24+
% supplied as input) and/or Account Name (when not supplied as input).
25+
%
26+
% Default Value: 'keyvaultsettings.json'
27+
%
28+
% 'Credentials', explicitly specify credentials to use. This for example
29+
% allows building multiple clients based on the same credentials
30+
% without having to go through (interactive) authentication again. If
31+
% not specified, createKeyVaultClient uses configureCredentials with
32+
% 'ConfigurationFile' as input to first configure credentials before
33+
% building the client.
34+
%
35+
% Hint: configureCredentials can be used to build valid Credentials.
36+
%
37+
% Example:
38+
% credentials = configureCredentials('myCredentials.json');
39+
% client1 = createKeyVaultClient('Credentials',credentials,'Type','Key')
40+
% client2 = createKeyVaultClient('Credentials',credentials,'Type','Secret')
41+
%
42+
% 'VaultName', explicitly specify the Vault name for the client. If not
43+
% specified createKeyVaultClient uses loadConfigurationSettings to
44+
% load configuration options from 'ConfigurationFile'. This file must
45+
% then contain a "VaultName" setting.
46+
%
47+
% See also CONFIGURECREDENTIALS, LOADCONFIGURATIONSETTINGS
4848

49-
% Copyright 2022 The MathWorks, Inc.
49+
% Copyright 2022 The MathWorks, Inc.
5050

5151
initialize('displayLevel', 'debug', 'loggerPrefix', 'Azure:KeyVault');
52-
52+
5353
logObj = Logger.getLogger();
5454

5555
p = inputParser;
5656
p.FunctionName = 'createKeyVaultClient';
57-
57+
5858
p.addParameter('Credentials',[],...
5959
@(x) isa(x, 'azure.core.credential.TokenCredential'));
60-
60+
6161
p.addParameter('Type',[],@(x) ischar(x) || isStringScalar(x));
6262
p.addParameter('ConfigurationFile','keyvaultsettings.json',@(x) ischar(x) || isStringScalar(x))
6363
p.addParameter('VaultName',[],@(x) ischar(x) || isStringScalar(x));
64-
64+
6565
p.parse(varargin{:});
66-
66+
6767
if isempty(p.Results.Credentials)
6868
credentials = configureCredentials(p.Results.ConfigurationFile);
6969
else
@@ -90,9 +90,10 @@
9090
vaultUrl = sprintf('https://%s.vault.azure.net/',config.VaultName);
9191
else
9292
vaultUrl = sprintf('https://%s.vault.azure.net/',p.Results.VaultName);
93-
end
93+
end
9494
builder = builder.vaultUrl(vaultUrl);
95-
95+
9696
builder = builder.httpClient();
9797

9898
client = builder.buildClient();
99+
end

Software/MATLAB/app/functions/createStorageClient.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@
189189
end
190190
if isempty(p.Results.AccountName)
191191
config = loadConfigurationSettings(p.Results.ConfigurationFile);
192-
endpoint = sprintf('https://%s.%s.core.windows.net',config.AccountName,resource);
192+
if isfield(config, 'AccountName')
193+
endpoint = sprintf('https://%s.%s.core.windows.net',config.AccountName,resource);
194+
else
195+
write(logObj,'error','AccountName not provided as a named argument or set in the JSON configuration file, an AccountName is required.')
196+
end
193197
else
194198
endpoint = sprintf('https://%s.%s.core.windows.net',p.Results.AccountName,resource);
195199
end

Software/MATLAB/app/system/+azure/+storage/+blob/+models/@BlobContainerItem/BlobContainerItem.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef BlobContainerItem < azure.object
2-
% BLOBCONTAINERITEM
2+
% BLOBCONTAINERITEM An Azure Storage container
33

4-
% Copyright 2020 The MathWorks, Inc.
4+
% Copyright 2020-2023 The MathWorks, Inc.
55

66
properties
77
end
@@ -15,7 +15,7 @@
1515
else
1616
logObj = Logger.getLogger();
1717
write(logObj,'error','Expected argument of type com.azure.storage.blob.models.BlobContainerItem');
18-
end
18+
end
1919
else
2020
logObj = Logger.getLogger();
2121
write(logObj,'error','Unexpected number of arguments');

Software/MATLAB/app/system/+azure/+storage/+blob/+models/@BlobContainerItem/getName.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function name = getName(obj)
2-
% GETNAME Returns the blob's name as a character vector
2+
% GETNAME Returns the container's name as a character vector
33

4-
% Copyright 2020 The MathWorks, Inc.
4+
% Copyright 2020-2023 The MathWorks, Inc.
55

66
name = char(obj.Handle.getName);
77

0 commit comments

Comments
 (0)