To switch a name server between master and slave mode, use the switch operation. You can switch multiple name servers in a single packet. To retrieve the zone type, refer to the Retrieving Parameters of SOA Record and Zone section.

Request Packet Structure

A request XML packet changing name server mode includes the switch operation node:

<packet>
<dns>
   <switch>
   ...
   </switch>
</dns>
</packet>

The graphical representation of the switch node is as follows:

image 34994

Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.

  • The filter node is required. It specifies the filtering rule. For more information, refer to the Available Filters section. Data type: simpleFilterType (dns_input.xsd) .
  • The zone_type node is required. Specifies the zone parameters. Data type: string. Allowed values: master | slave.

You can change mode of multiple name servers in a single packet. Add as many switch operations as the number of different filtering rules, you use to change the mode of name servers you need.

<dns>
   <switch>
   ...
   </switch>
...
   <switch>
   ...
   </switch>
</dns>

Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.

Response Packet Structure

The switch node of the output XML packet is structured as follows:

image 34997

Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.

  • The result node is required. It wraps the response from the server. Data type: resultType (common.xsd).
  • The status node is required. It specifies the execution status of the get operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. It is used to return the error code when the switch operation fails. Data type: unsignedInt
  • The errtext node is optional. It is used to return the error message if the switch operation fails. Data type: string.
  • The site-id node is optional. It is required if the site ID was set as a filtering rule in the request packet. Data type: integer.
  • The site-alias-id node is optional. It is required if the site alias ID was set as a filtering rule in the request packet. Data type: integer.

Samples

Changing status of a single name server

This request packet makes the DNS server act as a secondary for the zone specified by site ID 1.

<packet>
<dns>
 <switch>
  <filter>
   <site-id>1</site-id>
  </filter>
  <zone_type>slave</zone_type>
 </switch>
</dns>
</packet>

Response:

<packet>
<dns>
 <switch>
  <result>
   <status>ok</status>
   <site-id>1</site-id>
  </result>
 </switch>
</dns>
</packet>

Changing status of multiple name servers

This packet makes the DNS server act as a secondary for the zones specified by sites ID 1 and ID 2.

<packet>
<dns>
 <switch>
  <filter>
   <site-id>1</site-id>
   <site-id>2</site-id>
  </filter>
  <zone_type>slave</zone_type>
 </switch>
</dns>
</packet>

Response (when the site with ID 2 was not found):

<packet>
<dns>
 <switch>
  <result>
   <status>ok</status>
   <site-id>1</site-id>
  </result>
  <result>
   <status>error</status>
   <errcode>1015</errcode>
   <errtext>site does not exist</errtext>
   <site-id>2</site-id>
  </result>
 </switch>
</dns>
</packet>