Bulk copy a single property (legacy)

Bulk copy a single property (legacy)

This is the legacy way to bulk copy a property. For the latest bulk copy method that provides a way to bulk copy multiple properties, see Bulk copy multiple properties from a node source.

POST api/properties/property_template_name/values

Copy a property value from a node or node group to one or more targets.

Request syntax

post api/properties/<property_template_name>/values '{"source":{"hostname":"sit0001red0"},"target": {"hostnames": ["sit0001red0","sit0001red1"],"group_names": ["Node Group 1","Node Group 2"]}}'

Request parameters

The request accepts the following data in JSON format.

ParameterTypeDescriptionRequired
sourceHashThe source node or node group that contains the property value to be copied. You can specify only one source per request.Yes
targetHashThe target details to copy the property value to.Yes

Source hash parameters

The source hash parameter accepts the following parameters.

ParameterTypeDescriptionRequired
property template nameStringThe property template name is specified as part of the endpoint path.Yes
hostnameStringThe hostname of the node that contains the property value to be copied.Only if group_name isn't present or empty.
group_nameStringThe name of the node group that contains the property value to be copied.Only if hostname isn't present or empty.

Target hash parameters

The target hash parameter accepts the following parameters.

ParameterTypeDescriptionRequired
hostnamesString arrayThe list of target node hostnames to copy the property values to.Only if group_names, saved_filter_id, or saved_filter_name is not present or empty.
group_namesString arrayThe list of node group names to copy the property values to.Only if hostnames, saved_filter_id, or saved_filter_name is not present or empty.
saved_filter_idIntegerThe property value is copied to all nodes filtered by this saved filter. It only accepts filters that apply to nodes.Only if hostnames, saved_filter_name, or group_names is not present or empty.
saved_filter_nameStringThe property value is copied to all nodes filtered by this saved filter. It only accepts filters that apply to nodes.Only if hostnames, saved_filter_id, or group_names is not present or empty.

Response syntax

{
  "successful_target_count": integer,
  "failed_target_count": integer,
  "failed_targets": [
    {
      "hostname": "string",
      "message": "string"
    }
  ]
}

Response parameters

If the action is successful, an HTTP 200 response is returned. The following data is returned in JSON format.

FieldTypeDescription
successful_target_countIntegerThe number of successful copies.
failed_target_countIntegerThe number of failed copies.
failed targetsString arrayThe details of each failed copy. The hostname or group_name is included with an error message.
exporter_jobIntegerThe ID of the exporter job carrying out the request.

Errors

The following are common errors returned by this API.

CodeMessageCause
200Source property not enabled.The property being copied from the source doesn't exist on the target.
400Validation Failed: source is missingThe request has no source.
422Source property not found.The property does not exist on the source node or node group.

Examples

Example 1: Bulk copy a property value from one node to multiple target nodes.

This example bulk copies the value of the my_docker_app1_tag property from node sit0018red0 to nodes sit0022red0 and sit0022red1.

ruby api.rb <customer_code> post api/properties/my_docker_app1_tag/values '{"source": {"hostname": "sit0018red0"},"target": {"hostnames": ["sit0022red0","sit0022red1"]}}'

Response

{
  "successful_target_count": 2,
  "failed_target_count": 0,
  "exporter_job": 1563582
}

Example 2: Bulk copy a property value from one node to multiple target node groups.

This example bulk copies the value of property my_bridge0 from node sit0018red0 to node groups RedBox NA and RedBox SA.

ruby api.rb <customer_code> post api/properties/my_bridge0/values '{"source": {"hostname": "sit0018red0"},"target": {"group_names": ["RedBox NA","Redbox SA"]}}'

The response has the same format as the response in Example 1.

Example 3: Bulk copy a property value from one node to a mixed target of nodes and node groups.

This example bulk copies the value of the my_bridge0 property from node sit0018red0 to nodes sit0022red0 and sit0022red1 and to node groups RedBox NA and RedBox SA.

ruby api.rb <customer_code> post api/properties/my_bridge0/values '{"source": {"hostname": "sit0018red0"},"target": {"hostnames": ["sit0022red0","sit0022red1"],"group_names":["RedBox NA","RedBox SA"]}}'

The response has the same format as the response in Example 1.