DeleteTags() private method

private DeleteTags ( DeleteTagsRequest request ) : DeleteTagsResponse
request DeleteTagsRequest
return DeleteTagsResponse
示例#1
0
文件: Generator.cs 项目: srcliq/cliq
        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);
            }
        }