public override Task DeleteObjectAsync(
     string bucket,
     string objectName,
     DeleteObjectOptions options         = null,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Task.Run(() => DeleteObject(bucket, objectName, options)));
 }
        public void WrongGeneration(string bucket)
        {
            var obj     = CreateObjects(bucket, 1)[0];
            var options = new DeleteObjectOptions {
                Generation = obj.Generation.Value + 1
            };
            var exception = Assert.Throws <GoogleApiException>(() => s_config.Client.DeleteObject(obj, options));

            Assert.Equal(HttpStatusCode.NotFound, exception.HttpStatusCode);
        }
        // *************************************************************************************************************
        // DELETE OBJECT

        public override void DeleteObject(string bucket, string objectName, DeleteObjectOptions options = null)
        {
            var key = Key(bucket, objectName);

            if (_entries.TryRemove(key, out var _))
            {
                return;
            }
            // FIXME: Google compatible exception
            throw new InvalidOperationException($"No object found for {key}.");
        }
Beispiel #4
0
        public void WrongGeneration(bool multiVersionBucket)
        {
            string bucket  = multiVersionBucket ? _fixture.MultiVersionBucket : _fixture.SingleVersionBucket;
            var    obj     = CreateObjects(bucket, 1)[0];
            var    options = new DeleteObjectOptions {
                Generation = obj.Generation.Value + 1
            };
            var exception = Assert.Throws <GoogleApiException>(() => _fixture.Client.DeleteObject(obj, options));

            Assert.Equal(HttpStatusCode.NotFound, exception.HttpStatusCode);
        }
Beispiel #5
0
        public void ModifyRequest_DefaultOptions()
        {
            var request = new DeleteRequest(null, "bucket", "object");
            var options = new DeleteObjectOptions();

            options.ModifyRequest(request);
            Assert.Null(request.Generation);
            Assert.Null(request.IfGenerationMatch);
            Assert.Null(request.IfGenerationNotMatch);
            Assert.Null(request.IfMetagenerationMatch);
            Assert.Null(request.IfMetagenerationNotMatch);
        }
Beispiel #6
0
        public void MultipleVersionsCreated_MultiVersionBucket()
        {
            var bucket  = _fixture.MultiVersionBucket;
            var objects = CreateObjects(bucket, 3);

            for (int i = 0; i < 3; i++)
            {
                var options = new DeleteObjectOptions {
                    Generation = objects[i].Generation
                };
                _fixture.Client.DeleteObject(objects[0], options);
                Assert.Equal(2 - i, ListObjects(objects[0], true).Count);
            }
        }
        public void DeleteSameGenerationTwice(string bucket)
        {
            var obj     = CreateObjects(bucket, 1)[0];
            var options = new DeleteObjectOptions {
                Generation = obj.Generation.Value
            };

            // First time is fine
            s_config.Client.DeleteObject(obj, options);
            // Second time throws an exception
            var exception = Assert.Throws <GoogleApiException>(() => s_config.Client.DeleteObject(obj, options));

            Assert.Equal(HttpStatusCode.NotFound, exception.HttpStatusCode);
        }
Beispiel #8
0
        public void DeleteSameGenerationTwice(bool multiVersionBucket)
        {
            string bucket  = multiVersionBucket ? _fixture.MultiVersionBucket : _fixture.SingleVersionBucket;
            var    obj     = CreateObjects(bucket, 1)[0];
            var    options = new DeleteObjectOptions {
                Generation = obj.Generation.Value
            };

            // First time is fine
            _fixture.Client.DeleteObject(obj, options);
            // Second time throws an exception
            var exception = Assert.Throws <GoogleApiException>(() => _fixture.Client.DeleteObject(obj, options));

            Assert.Equal(HttpStatusCode.NotFound, exception.HttpStatusCode);
        }
Beispiel #9
0
        public void ModifyRequest_NegativeMatchOptions()
        {
            var request = new DeleteRequest(null, "bucket", "object");
            var options = new DeleteObjectOptions
            {
                IfGenerationNotMatch     = 1L,
                IfMetagenerationNotMatch = 2L,
                Generation = 3L
            };

            options.ModifyRequest(request);
            Assert.Null(request.IfGenerationMatch);
            Assert.Equal(1L, request.IfGenerationNotMatch);
            Assert.Null(request.IfMetagenerationMatch);
            Assert.Equal(2L, request.IfMetagenerationNotMatch);
            Assert.Equal(3L, request.Generation);
        }
        public void Delete(IEnumerable<PortableDeviceObject> objects, DeleteObjectOptions opts = DeleteObjectOptions.NO_RECURSION)
        {
            IPortableDeviceContent content;
            portableDeviceClass.Content(out content);
            var objectIds = (IPortableDevicePropVariantCollection) new PortableDevicePropVariantCollection();

            foreach (var obj in objects)
            {
                tag_inner_PROPVARIANT propvarValue;
                ConvertObjectsIdToPropVariant(obj, out propvarValue);

                objectIds.Add(propvarValue);
            }

            IPortableDevicePropVariantCollection results = null;
            content.Delete((uint)opts, objectIds, ref results);
        }
Beispiel #11
0
        public void ModifyRequest_MatchNotMatchConflicts()
        {
            var request = new DeleteRequest(null, "bucket", "object");

            Assert.Throws <ArgumentException>(() =>
            {
                var options = new DeleteObjectOptions {
                    IfGenerationMatch = 1L, IfGenerationNotMatch = 2L
                };
                options.ModifyRequest(request);
            });
            Assert.Throws <ArgumentException>(() =>
            {
                var options = new DeleteObjectOptions {
                    IfMetagenerationMatch = 1L, IfMetagenerationNotMatch = 2L
                };
                options.ModifyRequest(request);
            });
        }
        public void Delete(IEnumerable <PortableDeviceObject> objects, DeleteObjectOptions opts = DeleteObjectOptions.NO_RECURSION)
        {
            IPortableDeviceContent content;

            portableDeviceClass.Content(out content);
            var objectIds = (IPortableDevicePropVariantCollection) new PortableDevicePropVariantCollection();

            foreach (var obj in objects)
            {
                tag_inner_PROPVARIANT propvarValue;
                ConvertObjectsIdToPropVariant(obj, out propvarValue);

                objectIds.Add(propvarValue);
            }

            IPortableDevicePropVariantCollection results = null;

            content.Delete((uint)opts, objectIds, ref results);
        }
 public override Task DeleteObjectAsync(Object obj, DeleteObjectOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Task.Run(() => DeleteObject(obj, options)));
 }
 public override void DeleteObject(Object obj, DeleteObjectOptions options = null)
 {
     DeleteObject(obj.Bucket, obj.Name, options);
 }
 public void Delete(PortableDeviceObject obj, DeleteObjectOptions opts = DeleteObjectOptions.NO_RECURSION)
 {
     Delete(new[] { obj }, opts);
 }
 public void Delete(PortableDeviceObject obj, DeleteObjectOptions opts = DeleteObjectOptions.NO_RECURSION)
 {
     Delete(new[] {obj}, opts);
 }