Esempio n. 1
0
        private static void ChangeInstanceTags(int changeType)
        {
            IAmazonEC2 ec2 = new Amazon.EC2.AmazonEC2Client();
            DescribeInstancesResponse instanceResponse = ec2.DescribeInstances();
            var resourceIdList = new List <string>();
            var tagsList       = new List <Tag>();

            tagsList.Add(new Tag {
                Key = "Test1-AutoAdded", Value = "ToInduceConfigChages"
            });
            tagsList.Add(new Tag {
                Key = "Test2-AutoAdded", Value = "ToInduceConfigChages"
            });
            foreach (var reservation in instanceResponse.Reservations)
            {
                foreach (var rInstance in reservation.Instances)
                {
                    resourceIdList.Add(rInstance.InstanceId);
                }
            }
            if (changeType == 0)
            {
                var createTagsRequest = new CreateTagsRequest(resourceIdList, tagsList);
                ec2.CreateTags(createTagsRequest);
            }
            else if (changeType == 1)
            {
                var deleteTagsRequest = new DeleteTagsRequest();
                deleteTagsRequest.Resources = resourceIdList;
                deleteTagsRequest.Tags      = tagsList;
                ec2.DeleteTags(deleteTagsRequest);
            }
        }
Esempio n. 2
0
        internal DeleteTagsResponse DeleteTags(DeleteTagsRequest request)
        {
            var marshaller   = new DeleteTagsRequestMarshaller();
            var unmarshaller = DeleteTagsResponseUnmarshaller.Instance;

            return(Invoke <DeleteTagsRequest, DeleteTagsResponse>(request, marshaller, unmarshaller));
        }
Esempio n. 3
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteTags operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteTags operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <DeleteTagsResponse> DeleteTagsAsync(DeleteTagsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new DeleteTagsRequestMarshaller();
            var unmarshaller = DeleteTagsResponseUnmarshaller.Instance;

            return(InvokeAsync <DeleteTagsRequest, DeleteTagsResponse>(request, marshaller,
                                                                       unmarshaller, cancellationToken));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteTags operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteTags operation on AmazonWorkSpacesClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteTags
        ///         operation.</returns>
        public IAsyncResult BeginDeleteTags(DeleteTagsRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new DeleteTagsRequestMarshaller();
            var unmarshaller = DeleteTagsResponseUnmarshaller.Instance;

            return(BeginInvoke <DeleteTagsRequest>(request, marshaller, unmarshaller,
                                                   callback, state));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteTags operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteTags operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mq-2017-11-27/DeleteTags">REST API Reference for DeleteTags Operation</seealso>
        public virtual Task <DeleteTagsResponse> DeleteTagsAsync(DeleteTagsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DeleteTagsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DeleteTagsResponseUnmarshaller.Instance;

            return(InvokeAsync <DeleteTagsResponse>(request, options, cancellationToken));
        }
        internal virtual DeleteTagsResponse DeleteTags(DeleteTagsRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = DeleteTagsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DeleteTagsResponseUnmarshaller.Instance;

            return(Invoke <DeleteTagsResponse>(request, options));
        }
Esempio n. 7
0
        /// <summary>
        /// Deletes tag from specified instance.
        /// </summary>
        /// <param name="instanceId">InstanceId</param>
        /// <param name="tag">Tag (key-value pair)</param>
        public void DeleteTag(string instanceId, DeleteTags tag)
        {
            if (tag == null)
            {
                return;
            }

            DeleteTagsRequest deleteTagsRequest = new DeleteTagsRequest()
                                                  .WithResourceId(instanceId)
                                                  .WithTag(tag);

            _ec2.DeleteTags(deleteTagsRequest);
        }
Esempio n. 8
0
        public override async Task <Reply> DeleteTags(DeleteTagsRequest request, ServerCallContext context)
        {
            var reply = new Reply();
            var user  = await _userService.GetUser(context.GetHttpContext());

            if (user == null)
            {
                reply.Error = Error.NeedLogin;
                return(reply);
            }

            if (!user.HasWritePermission())
            {
                reply.Error = Error.NoPermission;
                return(reply);
            }

            if (!Guid.TryParse(request.Id, out var id))
            {
                reply.Error = Error.InvalidArguments;
                return(reply);
            }

            var item = await _service.All().Where(i => i.Id == id).Include(i => i.FileTags).FirstOrDefaultAsync();

            if (item == null)
            {
                reply.Error = Error.NoSuchEntity;
                return(reply);
            }

            if (item.FileTags != null)
            {
                var deletes = request.Tags.Select(t => Guid.Parse(t.TagId)).ToHashSet();
                item.FileTags = item.FileTags.Where(t => !deletes.Contains(t.TagId)).ToList();
                await _service.Update(item);

                if (item.Type == (int)FileType.Folder)
                {
                    await ClearFolderVersionsCache();
                }
            }

            return(reply);
        }