Modify a Data Center by ID
1 min
code examples curl request put \\ \ url 'https //api ionos com/cloudapi/v6/datacenters/{datacenterid}?pretty=true\&depth=integer%3cint32%3e' \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ data '{ "properties" { "location" "us/las" }, "entities" { "servers" { "type" {}, "items" \[ { "type" {}, "properties" { "bootcdrom" { "id" "", "type" {} }, "bootvolume" { "id" "", "type" {} } } } ] }, "volumes" { "type" {}, "items" \[ { "type" {}, "properties" { "size" 100, "requirelegacybios" true, "bootorder" "auto" } } ] }, "loadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "lans" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "networkloadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my network load balancer", "listenerlan" 1, "targetlan" 2 } } ] }, "natgateways" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my nat gateway", "publicips" \[], "lans" \[ { "id" 3 } ] } } ] }, "securitygroups" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my security group" } } ] } } }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); var raw = json stringify({ "properties" { "location" "us/las" }, "entities" { "servers" { "type" {}, "items" \[ { "type" {}, "properties" { "bootcdrom" { "id" "", "type" {} }, "bootvolume" { "id" "", "type" {} } } } ] }, "volumes" { "type" {}, "items" \[ { "type" {}, "properties" { "size" 100, "requirelegacybios" true, "bootorder" "auto" } } ] }, "loadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "lans" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "networkloadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my network load balancer", "listenerlan" 1, "targetlan" 2 } } ] }, "natgateways" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my nat gateway", "publicips" \[], "lans" \[ { "id" 3 } ] } } ] }, "securitygroups" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my security group" } } ] } } }); var requestoptions = { method 'put', headers myheaders, body raw, redirect 'follow' }; fetch("https //api ionos com/cloudapi/v6/datacenters/{datacenterid}?pretty=true\&depth=integer\<int32>", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("https //api ionos com/cloudapi/v6/datacenters/{datacenterid}?pretty=true\&depth=integer\<int32>") https = net http new(url host, url port) https use ssl = true request = net http put new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request body = json dump({ "properties" { "location" "us/las" }, "entities" { "servers" { "type" {}, "items" \[ { "type" {}, "properties" { "bootcdrom" { "id" "", "type" {} }, "bootvolume" { "id" "", "type" {} } } } ] }, "volumes" { "type" {}, "items" \[ { "type" {}, "properties" { "size" 100, "requirelegacybios" true, "bootorder" "auto" } } ] }, "loadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "lans" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "networkloadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my network load balancer", "listenerlan" 1, "targetlan" 2 } } ] }, "natgateways" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my nat gateway", "publicips" \[], "lans" \[ { "id" 3 } ] } } ] }, "securitygroups" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my security group" } } ] } } }) response = https request(request) puts response read body import requests import json url = "https //api ionos com/cloudapi/v6/datacenters/{datacenterid}?pretty=true\&depth=integer\<int32>" payload = json dumps({ "properties" { "location" "us/las" }, "entities" { "servers" { "type" {}, "items" \[ { "type" {}, "properties" { "bootcdrom" { "id" "", "type" {} }, "bootvolume" { "id" "", "type" {} } } } ] }, "volumes" { "type" {}, "items" \[ { "type" {}, "properties" { "size" 100, "requirelegacybios" true, "bootorder" "auto" } } ] }, "loadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "lans" { "type" {}, "items" \[ { "type" {}, "properties" {} } ] }, "networkloadbalancers" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my network load balancer", "listenerlan" 1, "targetlan" 2 } } ] }, "natgateways" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my nat gateway", "publicips" \[], "lans" \[ { "id" 3 } ] } } ] }, "securitygroups" { "type" {}, "items" \[ { "type" {}, "properties" { "name" "my security group" } } ] } } }) headers = { 'accept' 'application/json', 'content type' 'application/json' } response = requests request("put", url, headers=headers, data=payload) print(response text) responses // successful operation { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "production datacenter", "description" "my production datacenter", "location" "us/las", "version" 8, "features" \[ "" ], "secauthprotection" true, "cpuarchitecture" \[ { "cpufamily" "intel icelake", "maxcores" 62, "maxram" 245760, "vendor" "authenticamd", "enabledfeatures" \[ "" ] } ], "gpuarchitecture" \[ { "vendor" "nvidia", "model" "a100" } ], "ipv6cidrblock" "2001\ db8\ b06d 8f00 /56", "defaultsecuritygroupid" "15f67991 0f51 4efc a8ad ef1fb31a480c" }, "entities" { "servers" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "templateuuid" "15f67991 0f51 4efc a8ad ef1fb31a480c", "name" "my resource", "hostname" "myhostname", "cores" 4, "ram" 4096, "availabilityzone" "auto", "vmstate" "running", "bootcdrom" {}, "bootvolume" {}, "cpufamily" "intel icelake", "type" "cube", "enabledfeatures" \[ "" ], "placementgroupid" "", "nicmultiqueue" true, "maxnetworkbandwidth" 6 }, "entities" { "cdroms" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "volumes" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "nics" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "securitygroups" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "gpus" { "id" "25f67991 0f51 4efc a8ad ef1fb31a400c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } } } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } }, "volumes" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "my resource", "type" "hdd", "size" 100, "availabilityzone" "auto", "image" "d6ad1576 fde9 4696 aa41 1ebd75bdaf49", "imagepassword" "mypass123", "sshkeys" \[ "" ], "bus" "virtio", "licencetype" "linux", "applicationtype" "mssql 2019 standard", "cpuhotplug" true, "ramhotplug" true, "nichotplug" true, "nichotunplug" true, "discvirtiohotplug" true, "discvirtiohotunplug" true, "exposeserial" true, "requirelegacybios" true, "devicenumber" 3, "pcislot" 7, "backupunitid" "25f67991 0f51 4efc a8ad ef1fb31a481c", "userdata" "", "bootserver" "25f67991 0f51 4efc a8ad ef1fb31a481c", "bootorder" "auto" } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } }, "loadbalancers" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "my resource", "ip" "22 231 113 64", "dhcp" true }, "entities" { "balancednics" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } } } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } }, "lans" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "5", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "my resource", "ipfailover" \[ { "ip" "192 18 2 231", "nicuuid" "3c11273c b3e1 4ca3 8134 84fd2dd4ebec" } ], "ipv4cidrblock" "10 8 130 0/23", "ipv6cidrblock" "2001\ db8\ b06d 8f5a /64", "pcc" "3c11273c b3e1 4ca3 8134 84fd2dd4ebec", "public" true, "vni" 123 }, "entities" { "nics" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } } } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } }, "networkloadbalancers" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "my network load balancer", "listenerlan" 1, "ips" \[ "" ], "targetlan" 2, "lbprivateips" \[ "" ], "centrallogging" true, "loggingformat" "%{+q}o %{ q}ci \[%trg] %r %st %b \\"\\" \\"\\" %cp %ms %ft %b %s %tr %tw %tc %tr %ta %tsc %ac %fc %bc %sc %rc %sq %bq %cc %cs %hrl %hsl" }, "entities" { "flowlogs" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "forwardingrules" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } } } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } }, "natgateways" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "my nat gateway", "publicips" \[ "" ], "lans" \[ { "id" 3, "gatewayips" \[ "" ] } ] }, "entities" { "rules" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ] }, "flowlogs" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } } } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } }, "securitygroups" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "metadata" { "etag" "45480eb3fbfc31f1d916c1eaa4abdcc3", "createddate" "2015 12 04t14 34 09 809z", "createdby" "user\@example com", "createdbyuserid" "user\@example com", "lastmodifieddate" "2015 12 04t14 34 09 809z", "lastmodifiedby" "user\@example com", "lastmodifiedbyuserid" "63cef532 26fe 4a64 a4e0 de7c8a506c90", "state" "available" }, "properties" { "name" "my security group", "description" "my security group description" }, "entities" { "rules" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "nics" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } }, "servers" { "id" "15f67991 0f51 4efc a8ad ef1fb31a480c", "type" {}, "href" "\<resource uri>", "items" \[ { "" "" } ], "offset" 0, "limit" 1000, " links" { "" "" } } } } ], "offset" 0, "limit" 1000, " links" { "prev" "\<previous page uri>", "self" "\<this page uri>", "next" "\<next page uri>" } } } }// any erroneous status code 400 (parse error), 401 (auth error), 402 (trial access), 403 (insufficient privileges), 404 (not found), 405 (unsupported http method), 415 (unsupported content type, 422 (validation error), 429 (request rate limit exceeded), 500 (server error), or 503 (maintenance) { "httpstatus" 400, "messages" \[ { "errorcode" "123", "message" "error message example " } ] }