Bulk copy multiple properties from a node group source

Bulk copy multiple properties from a node group source

POST api/node_groups/node-group-id/copy_properties

Bulk copy property values from a node group source to one or more target nodes or node groups. This is useful when you've made a data configuration change on one node group and then want to deploy the changes in batches to your entire environment.

Request syntax

post api/node_groups/<node_group_id>/copy_properties '{"properties": ["my_property1","my_property2"],"target": {"hostnames": ["sit0001red0","sit0001red1"],"group_names": ["Node Group 1","Node Group 2"]}}'

Request parameters

The request accepts the following data in JSON format.

ParameterTypeDescriptionRequiredDefault value
propertiesString arrayThe list of property template names.YesN/A
targetHashThe target to copy the property values to.YesN/A

Details of the target hash parameter

The target hash parameter accepts the following keys.

KeyTypeDescriptionRequired
hostnamesString arrayThe list of target 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 values are 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 values are 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": [
        {
            "group_name": "string",
            "message": "string"
        },
        {
            "group_name": "string",
            "message": "string"
        }
    ],
    "exporter_job": integer
}

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 fatal errors returned by this API. When fatal errors are returned, no properties on the target are changed.

CodeMessageCause
400You need to specify at least one property.The properties parameter is empty. Specify at least one property and try again.
400Please enter a maximum of 15 properties.The number of properties exceeds the 15 properties limit.
400Please enter a maximum of 2000 targets.The number of targets exceeds the 2000 targets limit.
400You need to specify at least one target.The targets parameter is empty. Specify at least one target in the request and try again.
400Please only specify one Saved Filter parameter.Both the target[saved_filter_name] and target[saved_filter_id] were specified. Specify one or the other and try again.
400Filter id #{target[saved_filter_id]} does not exist.The filter ID specified doesn't exist. Verify the filter ID and try again.
400Filter name #{target[saved_filter_name]} does not exist.The filter name specified doesn't exist. Verify the filter name and try again.
404Not found.The hostname doesn't exist. Verify the hostname and try again.
422Source property #{template_name} not found.The property on the source doesn't exist. Verify the property name and try again.
422Source property #{template_name} has no value.The property value on the source is empty. Empty properties cannot be copied. Verify the property and try again.

The following are partial error messages returned by this API. When a partial error is returned, valid targets are updated and invalid targets fail and show an error message.

MessageCause
Property <property_name> not enabled.The specified property is not enabled on the target node group. Verify the property, ensure it's enabled on the target node group, and try again.

Examples

Example 1: Copy a property value successfully to multiple node groups by specifying the node group name.

This example copies the cluster_docker_resources property from node group ID 1953 to node group names test_group1 and test_group2.

ruby api.rb <customer_code> post api/node_groups/1953/copy_properties '{"properties": ["cluster_docker_resources"], "target":{"group_names": ["test_group1", "test_group2"]}}'

Response

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

Example 2: Copy a property successfully to multiple node groups by specifying both hostnames and node group names.

This example copies the cluster_docker_resources property from node group ID 1953 to hostnames sit0000red0 and sit0000red1 as well as node group names test_group1 and test_group2.

ruby api.rb <customer_code> post api/node_groups/1953/copy_properties '{"properties": ["cluster_docker_resources"], "target":{"hostnames":["sit0000red0","sit0000red1"], "group_names": ["test_group1", "test_group2"]}}'

Response

{   
    "successful_target_count": 4,
    "failed_target_count": 0,
    "exporter_job": 1538822
}

Example 3: Copy a property successfully to one node group and fail to another.

This example copies the cluster_docker_resources property from node group ID 1953 to node group names test_group1 and test_group2. The copy to test_group1 is successful, but you receive a partial failure copying to test_group2 because the property isn't enabled on that node group.

ruby api.rb <customer_code> post api/node_groups/1953/copy_properties '{"properties": ["cluster_docker_resources"], "target":{"group_names": ["test_group1", "test_group2"]}}'

Response

{   
    "successful_target_count": 1,
    "failed_target_count": 1,
    "failed_targets": [
        {
            "group_name": "test_group2",
            "message": "Property cluster_docker_resources not enabled."
        }
    ],
    "exporter_job": 1538822
}