# Given a list of nodes by name, "node_names", set the node attribute "attribute" to "value"
# if the node is in the "Frozen" state.


# The simple, slow, way - GET every node, check the condition and update if necessary

# set the node attribute "attribute" to "value" for my frozen nodes

for name in node_names
    node = GET https://netdb-dev-api.stanford.edu/nodes/{name}
    if (node["state"] == "Frozen")
        PUT https://netdb-dev-api.stanford.edu/nodes/{name}/attribute, {"attribute": "value"}





# The efficient way - search for nodes with the condition and update them

# set the node attribute "attribute" to "value" for my frozen nodes

search_string = join node_names elements with " or "
response = GET https://netdb-dev-api.stanford.edu/nodes/search,
                 { "name": search_string, "search node names": True, "state": "frozen" }

for node in response["search results"]
    name = node["names"][0]["name"]
    PUT https://netdb-dev-api.stanford.edu/nodes/{name}/attribute, {"attribute": "value"}





# The efficient way in optimum-sized chunks of size N

# set the node attribute "attribute" to "value" for my frozen nodes

base = 1
chunksize = N # recommended starting value between 100 and 200

while base < len(node_names)
    last = base + chunksize - 1
    search_string = join node_names elements base through last with " or "
    response = GET https://netdb-dev-api.stanford.edu/nodes/search,
                     { "name": search_string, "search node names": True, "state": "frozen" }

    for node in response["search results"]
        name = node["names"][0]["name"]
        PUT https://netdb-dev-api.stanford.edu/nodes/{name}/attribute, {"attribute": "value"}
    base = last