/// <summary>
        /// Creates a storage manifest on the remote OpenStack instance.
        /// </summary>
        /// <param name="manifest">The manifest to create.</param>
        /// <returns>An async task.</returns>
        internal async Task CreateStorageManifest(StorageManifest manifest)
        {
            manifest.AssertIsNotNull("manifest", "Cannot create a manifest that is null.");

            var dynoManifest   = manifest as DynamicLargeObjectManifest;
            var staticManifest = manifest as StaticLargeObjectManifest;

            if (dynoManifest == null && staticManifest == null)
            {
                throw new ArgumentException(string.Format("Cannot create manifest. The given manifest type '{0}' is not supported.", manifest.GetType().Name), "manifest");
            }

            if (dynoManifest != null)
            {
                await this.StorageClient.CreateStorageManifest(dynoManifest.ContainerName, dynoManifest.FullName, dynoManifest.Metadata, dynoManifest.SegmentsPath);
            }

            if (staticManifest != null)
            {
                await this.StorageClient.CreateStorageManifest(staticManifest.ContainerName, staticManifest.FullName, staticManifest.Metadata, staticManifest.Objects);
            }
        }
        public async Task <StorageManifest> CreateStorageManifest(StorageManifest manifest)
        {
            manifest.AssertIsNotNull("manifest", "Cannot create a null storage manifest.");
            manifest.ContainerName.AssertIsNotNullOrEmpty("manifest.ContainerName", "Cannot create a storage manifest with a null or empty container name.");
            manifest.Name.AssertIsNotNullOrEmpty("manifest.Name", "Cannot create a storage manifest without a name.");

            var client = this.GetRestClient();
            IHttpResponseAbstraction resp;

            var dynamicManifest = manifest as DynamicLargeObjectManifest;
            var staticManifest  = manifest as StaticLargeObjectManifest;

            if (dynamicManifest == null && staticManifest == null)
            {
                throw new InvalidOperationException(string.Format("Failed to create storage manifest '{0}'. The given manifest type is not supported: '{1}'.", manifest.Name, manifest.GetType().Name));
            }

            if (dynamicManifest != null) //dynamic large object manifest
            {
                resp = await client.CreateDynamicManifest(dynamicManifest.ContainerName, dynamicManifest.FullName, dynamicManifest.Metadata, dynamicManifest.SegmentsPath);
            }
            else //static large object manifest
            {
                var converter       = this.ServiceLocator.Locate <IStorageObjectPayloadConverter>();
                var manifestPayload = converter.Convert(staticManifest.Objects).ConvertToStream();

                resp = await client.CreateStaticManifest(staticManifest.ContainerName, staticManifest.FullName, staticManifest.Metadata, manifestPayload);
            }

            if (resp.StatusCode != HttpStatusCode.Created)
            {
                throw new InvalidOperationException(string.Format("Failed to create storage manifest '{0}'. The remote server returned the following status code: '{1}'.", manifest.Name, resp.StatusCode));
            }

            return(await this.GetStorageManifest(manifest.ContainerName, manifest.FullName));
        }
        /// <summary>
        /// Creates a storage manifest on the remote OpenStack instance.
        /// </summary>
        /// <param name="manifest">The manifest to create.</param>
        /// <returns>An async task.</returns>
        internal async Task CreateStorageManifest(StorageManifest manifest)
        {
            manifest.AssertIsNotNull("manifest", "Cannot create a manifest that is null.");

            var dynoManifest = manifest as DynamicLargeObjectManifest;
            var staticManifest = manifest as StaticLargeObjectManifest;
            if (dynoManifest == null && staticManifest == null)
            {
                throw new ArgumentException(string.Format("Cannot create manifest. The given manifest type '{0}' is not supported.", manifest.GetType().Name), "manifest");
            }

            if (dynoManifest != null)
            {
                await this.StorageClient.CreateStorageManifest(dynoManifest.ContainerName, dynoManifest.FullName, dynoManifest.Metadata, dynoManifest.SegmentsPath);
            }

            if (staticManifest != null)
            {
                await this.StorageClient.CreateStorageManifest(staticManifest.ContainerName, staticManifest.FullName, staticManifest.Metadata, staticManifest.Objects);
            }
        }
 public async Task<StorageManifest> CreateStorageManifest(StorageManifest manifest)
 {
     return await this.CreateStorageManifestDelegate(manifest);
 }
        public async Task<StorageManifest> CreateStorageManifest(StorageManifest manifest)
        {
            manifest.AssertIsNotNull("manifest", "Cannot create a null storage manifest.");
            manifest.ContainerName.AssertIsNotNullOrEmpty("manifest.ContainerName", "Cannot create a storage manifest with a null or empty container name.");
            manifest.Name.AssertIsNotNullOrEmpty("manifest.Name", "Cannot create a storage manifest without a name.");

            var client = this.GetRestClient();
            IHttpResponseAbstraction resp;

            var dynamicManifest = manifest as DynamicLargeObjectManifest;
            var staticManifest = manifest as StaticLargeObjectManifest;

            if (dynamicManifest == null && staticManifest == null)
            {
                throw new InvalidOperationException(string.Format("Failed to create storage manifest '{0}'. The given manifest type is not supported: '{1}'.", manifest.Name, manifest.GetType().Name));
            }

            if (dynamicManifest != null) //dynamic large object manifest
            {
                resp = await client.CreateDynamicManifest(dynamicManifest.ContainerName, dynamicManifest.FullName, dynamicManifest.Metadata, dynamicManifest.SegmentsPath);
            }
            else //static large object manifest
            {
                var converter = this.ServiceLocator.Locate<IStorageObjectPayloadConverter>();
                var manifestPayload = converter.Convert(staticManifest.Objects).ConvertToStream();

                resp = await client.CreateStaticManifest(staticManifest.ContainerName, staticManifest.FullName, staticManifest.Metadata, manifestPayload);
            }

            if (resp.StatusCode != HttpStatusCode.Created)
            {
                throw new InvalidOperationException(string.Format("Failed to create storage manifest '{0}'. The remote server returned the following status code: '{1}'.", manifest.Name, resp.StatusCode));
            }

            return await this.GetStorageManifest(manifest.ContainerName, manifest.FullName);
        }