CloudFilesProviderListObjects Method |
Lists the objects in a container.
Namespace: net.openstack.Providers.RackspaceAssembly: openstacknet (in openstacknet.dll) Version: 1.7.7+Branch.master.Sha.25d803f397c8693c2c13777ef6675f796f520f2c
Syntax public IEnumerable<ContainerObject> ListObjects(
string container,
Nullable<int> limit = null,
string marker = null,
string markerEnd = null,
string prefix = null,
string region = null,
bool useInternalUrl = false,
CloudIdentity identity = null
)
Public Function ListObjects (
container As String,
Optional limit As Nullable(Of Integer) = Nothing,
Optional marker As String = Nothing,
Optional markerEnd As String = Nothing,
Optional prefix As String = Nothing,
Optional region As String = Nothing,
Optional useInternalUrl As Boolean = false,
Optional identity As CloudIdentity = Nothing
) As IEnumerable(Of ContainerObject)
public:
virtual IEnumerable<ContainerObject^>^ ListObjects(
String^ container,
Nullable<int> limit = nullptr,
String^ marker = nullptr,
String^ markerEnd = nullptr,
String^ prefix = nullptr,
String^ region = nullptr,
bool useInternalUrl = false,
CloudIdentity^ identity = nullptr
) sealed
abstract ListObjects :
container : string *
?limit : Nullable<int> *
?marker : string *
?markerEnd : string *
?prefix : string *
?region : string *
?useInternalUrl : bool *
?identity : CloudIdentity
(* Defaults:
let _limit = defaultArg limit null
let _marker = defaultArg marker null
let _markerEnd = defaultArg markerEnd null
let _prefix = defaultArg prefix null
let _region = defaultArg region null
let _useInternalUrl = defaultArg useInternalUrl false
let _identity = defaultArg identity null
*)
-> IEnumerable<ContainerObject>
override ListObjects :
container : string *
?limit : Nullable<int> *
?marker : string *
?markerEnd : string *
?prefix : string *
?region : string *
?useInternalUrl : bool *
?identity : CloudIdentity
(* Defaults:
let _limit = defaultArg limit null
let _marker = defaultArg marker null
let _markerEnd = defaultArg markerEnd null
let _prefix = defaultArg prefix null
let _region = defaultArg region null
let _useInternalUrl = defaultArg useInternalUrl false
let _identity = defaultArg identity null
*)
-> IEnumerable<ContainerObject>
Parameters
- container
- Type: SystemString
The container name. - limit (Optional)
- Type: SystemNullableInt32
The maximum number of objects to return. If the value is , a provider-specific default is used. - marker (Optional)
- Type: SystemString
When specified, only objects with names greater than marker are returned. If the value is , the list starts at the beginning. - markerEnd (Optional)
- Type: SystemString
When specified, only objects with names less than markerEnd are returned. If the value is , the list proceeds to the end, or until the limit is reached. - prefix (Optional)
- Type: SystemString
Prefix of object names to include - region (Optional)
- Type: SystemString
The region in which to execute this action. If not specified, the user's default region will be used. - useInternalUrl (Optional)
- Type: SystemBoolean
to use the endpoint's InternalURL; otherwise to use the endpoint's PublicURL. - identity (Optional)
- Type: net.openstack.Core.DomainCloudIdentity
The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.
Return Value
Type:
IEnumerableContainerObjectA collection of
ContainerObject objects containing the details of the specified objects.
Implements
IObjectStorageProviderListObjects(String, NullableInt32, String, String, String, String, Boolean, CloudIdentity)Exceptions Examples The following example demonstrates the use of this method to output the names of all objects in a container
using WriteLine(String, Object). In the example, the pagination details of this method are handled by the
helper method ListAllObjects.
public void ListObjects(IObjectStorageProvider provider, string containerName)
{
Console.WriteLine("Objects in container {0}", containerName);
foreach (ContainerObject containerObject in ListAllObjects(provider, containerName))
Console.WriteLine(" {0}", containerObject.Name);
}
private static IEnumerable<ContainerObject> ListAllObjects(
IObjectStorageProvider provider,
string containerName,
int? blockSize = null,
string prefix = null,
string region = null,
bool useInternalUrl = false,
CloudIdentity identity = null)
{
if (blockSize <= 0)
throw new ArgumentOutOfRangeException("blockSize");
ContainerObject lastContainerObject = null;
do
{
string marker = lastContainerObject != null ? lastContainerObject.Name : null;
IEnumerable<ContainerObject> containerObjects =
provider.ListObjects(containerName, blockSize, marker, null, prefix, region, useInternalUrl, identity);
lastContainerObject = null;
foreach (ContainerObject containerObject in containerObjects)
{
lastContainerObject = containerObject;
yield return containerObject;
}
} while (lastContainerObject != null);
}
Public Sub ListObjects(provider As IObjectStorageProvider, containerName As String)
Console.WriteLine("Objects in container {0}", containerName)
For Each containerObject In ListAllObjects(provider, containerName)
Console.WriteLine(" {0}", containerObject.Name)
Next
End Sub
Private Shared Iterator Function ListAllObjects(
provider As IObjectStorageProvider,
containerName As String,
Optional blockSize As Nullable(Of Integer) = Nothing,
Optional prefix As String = Nothing,
Optional region As String = Nothing,
Optional useInternalUrl As Boolean = False,
Optional identity As CloudIdentity = Nothing) As IEnumerable(Of ContainerObject)
If blockSize <= 0 Then
Throw New ArgumentOutOfRangeException("blockSize")
End If
Dim lastContainerObject As ContainerObject = Nothing
Do
Dim marker = If(lastContainerObject IsNot Nothing, lastContainerObject.Name, Nothing)
Dim containerObjects = provider.ListObjects(containerName, blockSize, marker, Nothing, prefix, region, useInternalUrl, identity)
lastContainerObject = Nothing
For Each containerObject In containerObjects
lastContainerObject = containerObject
Yield containerObject
Next
Loop While lastContainerObject IsNot Nothing
End Function
void ListObjects(IObjectStorageProvider^ provider, String^ containerName)
{
Console::WriteLine("Objects in container {0}", containerName);
for each (ContainerObject^ containerObject in ListAllObjects(provider, containerName))
Console::WriteLine(" {0}", containerObject->Name);
}
static IEnumerable<ContainerObject^>^ ListAllObjects(IObjectStorageProvider^ provider, String^ containerName)
{
return ListAllObjects(provider, containerName, Nullable<int>(), nullptr, nullptr, false, nullptr);
}
static IEnumerable<ContainerObject^>^ ListAllObjects(
IObjectStorageProvider^ provider,
String^ containerName,
Nullable<int> blockSize,
String^ prefix,
String^ region,
bool useInternalUrl,
CloudIdentity^ identity)
{
if (blockSize.HasValue && blockSize.Value <= 0)
throw gcnew ArgumentOutOfRangeException("blockSize");
List<ContainerObject^>^ result = gcnew List<ContainerObject^>();
ContainerObject^ lastContainerObject = nullptr;
do
{
String^ marker = lastContainerObject ? lastContainerObject->Name : nullptr;
IEnumerable<ContainerObject^>^ containerObjects =
provider->ListObjects(containerName, blockSize, marker, nullptr, prefix, region, useInternalUrl, identity);
int previousCount = result->Count;
result->AddRange(containerObjects);
if (result->Count > previousCount)
lastContainerObject = result[result->Count - 1];
else
lastContainerObject = nullptr;
} while (lastContainerObject);
return result;
}
let listAllObjects(provider : IObjectStorageProvider, containerName : string) =
seq {
let lastContainerObject : ContainerObject ref = { contents = null }
let finished : bool ref = { contents = false }
while not !finished do
let marker = if !lastContainerObject <> null then (!lastContainerObject).Name else null
let containerObjects = provider.ListObjects(containerName, marker= marker)
lastContainerObject := null
for containerObject in containerObjects do
lastContainerObject := containerObject
yield containerObject
if !lastContainerObject = null then
finished := true
}
let listObjects(provider : IObjectStorageProvider, containerName : string) =
Console.WriteLine("Objects in container {0}", containerName)
for containerObject in listAllObjects(provider, containerName) do
Console.WriteLine(" {0}", containerObject.Name)
()
Version Information .NET Framework
Supported in: 4.5
openstack.net
Supported in: 1.6, 1.5, 1.4, 1.3.6
See Also