DigitalOcean.API.Clients.TagsClient.Untag C# (CSharp) Метод

Untag() публичный Метод

Untag existing resources of given resource id / type combination
public Untag ( string tagName, string>.List resources ) : System.Threading.Tasks.Task
tagName string
resources string>.List
Результат System.Threading.Tasks.Task
        public Task Untag(string tagName, List<KeyValuePair<string, string>> resources) {
            var data = new Models.Requests.TagResource {
                Resources = new List<Models.Requests.TagResource.Resource>()
            };

            foreach (KeyValuePair<string, string> resource in resources) {
                data.Resources.Add(new Models.Requests.TagResource.Resource {
                    Id = resource.Key,
                    Type = resource.Value
                });
            }

            var parameters = new List<Parameter> {
                new Parameter { Name = "name", Value = tagName, Type = ParameterType.UrlSegment }
            };

            return _connection.ExecuteRaw("tags/{name}/resources", parameters, data, Method.DELETE);
        }

Usage Example

Пример #1
0
        public void CorrectRequestForUntag() {
            var factory = Substitute.For<IConnection>();
            var client = new TagsClient(factory);

            List<KeyValuePair<string, string>> resources = new List<KeyValuePair<string, string>>(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("9001", "droplet"),
                new KeyValuePair<string, string>("9002", "droplet")
            });

            client.Untag("notarealtag", resources);

            var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "notarealtag");
            factory.Received().ExecuteRaw("tags/{name}/resources", parameters, Arg.Is<Models.Requests.TagResource>(data => data.Resources[1].Id == "9002"), Method.DELETE);
        }