# File Mandrill/Ips.php

      1: <?php
      2:
      3: class Mandrill_Ips {
      4:     public function __construct(Mandrill $master) {
      5:         $this->master = $master;
      6:     }
      7:
      8:     /**
      9:      * Lists your dedicated IPs.
     10:      * @return array an array of structs for each dedicated IP
     11:      *     - return[] struct information about a single dedicated IP
     12:      *         - ip string the ip address
     13:      *         - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     14:      *         - pool string the name of the pool that this dedicated IP belongs to
     15:      *         - domain string the domain name (reverse dns) of this dedicated IP
     16:      *         - custom_dns struct information about the ip's custom dns, if it has been configured
     17:      *             - enabled boolean a boolean indicating whether custom dns has been configured for this ip
     18:      *             - valid boolean whether the ip's custom dns is currently valid
     19:      *             - error string if the ip's custom dns is invalid, this will include details about the error
     20:      *         - warmup struct information about the ip's warmup status
     21:      *             - warming_up boolean whether the ip is currently in warmup mode
     22:      *             - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
     23:      *             - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
     24:      */
     25:     public function getList() {
     26:         $_params = array();
     27:         return $this->master->call('ips/list', $_params);
     28:     }
     29:
     30:     /**
     31:      * Retrieves information about a single dedicated ip.
     32:      * @param string $ip a dedicated IP address
     33:      * @return struct Information about the dedicated ip
     34:      *     - ip string the ip address
     35:      *     - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     36:      *     - pool string the name of the pool that this dedicated IP belongs to
     37:      *     - domain string the domain name (reverse dns) of this dedicated IP
     38:      *     - custom_dns struct information about the ip's custom dns, if it has been configured
     39:      *         - enabled boolean a boolean indicating whether custom dns has been configured for this ip
     40:      *         - valid boolean whether the ip's custom dns is currently valid
     41:      *         - error string if the ip's custom dns is invalid, this will include details about the error
     42:      *     - warmup struct information about the ip's warmup status
     43:      *         - warming_up boolean whether the ip is currently in warmup mode
     44:      *         - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
     45:      *         - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
     46:      */
     47:     public function info($ip) {
     48:         $_params = array("ip" => $ip);
     49:         return $this->master->call('ips/info', $_params);
     50:     }
     51:
     52:     /**
     53:      * Requests an additional dedicated IP for your account. Accounts may
     54: have one outstanding request at any time, and provisioning requests
     55: are processed within 24 hours.
     56:      * @param boolean $warmup whether to enable warmup mode for the ip
     57:      * @param string $pool the id of the pool to add the dedicated ip to, or null to use your account's default pool
     58:      * @return struct a description of the provisioning request that was created
     59:      *     - requested_at string the date and time that the request was created as a UTC timestamp in YYYY-MM-DD HH:MM:SS format
     60:      */
     61:     public function provision($warmup=false, $pool=null) {
     62:         $_params = array("warmup" => $warmup, "pool" => $pool);
     63:         return $this->master->call('ips/provision', $_params);
     64:     }
     65:
     66:     /**
     67:      * Begins the warmup process for a dedicated IP. During the warmup process,
     68: Mandrill will gradually increase the percentage of your mail that is sent over
     69: the warming-up IP, over a period of roughly 30 days. The rest of your mail
     70: will be sent over shared IPs or other dedicated IPs in the same pool.
     71:      * @param string $ip a dedicated ip address
     72:      * @return struct Information about the dedicated IP
     73:      *     - ip string the ip address
     74:      *     - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     75:      *     - pool string the name of the pool that this dedicated IP belongs to
     76:      *     - domain string the domain name (reverse dns) of this dedicated IP
     77:      *     - custom_dns struct information about the ip's custom dns, if it has been configured
     78:      *         - enabled boolean a boolean indicating whether custom dns has been configured for this ip
     79:      *         - valid boolean whether the ip's custom dns is currently valid
     80:      *         - error string if the ip's custom dns is invalid, this will include details about the error
     81:      *     - warmup struct information about the ip's warmup status
     82:      *         - warming_up boolean whether the ip is currently in warmup mode
     83:      *         - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
     84:      *         - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
     85:      */
     86:     public function startWarmup($ip) {
     87:         $_params = array("ip" => $ip);
     88:         return $this->master->call('ips/start-warmup', $_params);
     89:     }
     90:
     91:     /**
     92:      * Cancels the warmup process for a dedicated IP.
     93:      * @param string $ip a dedicated ip address
     94:      * @return struct Information about the dedicated IP
     95:      *     - ip string the ip address
     96:      *     - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     97:      *     - pool string the name of the pool that this dedicated IP belongs to
     98:      *     - domain string the domain name (reverse dns) of this dedicated IP
     99:      *     - custom_dns struct information about the ip's custom dns, if it has been configured
    100:      *         - enabled boolean a boolean indicating whether custom dns has been configured for this ip
    101:      *         - valid boolean whether the ip's custom dns is currently valid
    102:      *         - error string if the ip's custom dns is invalid, this will include details about the error
    103:      *     - warmup struct information about the ip's warmup status
    104:      *         - warming_up boolean whether the ip is currently in warmup mode
    105:      *         - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    106:      *         - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    107:      */
    108:     public function cancelWarmup($ip) {
    109:         $_params = array("ip" => $ip);
    110:         return $this->master->call('ips/cancel-warmup', $_params);
    111:     }
    112:
    113:     /**
    114:      * Moves a dedicated IP to a different pool.
    115:      * @param string $ip a dedicated ip address
    116:      * @param string $pool the name of the new pool to add the dedicated ip to
    117:      * @param boolean $create_pool whether to create the pool if it does not exist; if false and the pool does not exist, an Unknown_Pool will be thrown.
    118:      * @return struct Information about the updated state of the dedicated IP
    119:      *     - ip string the ip address
    120:      *     - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
    121:      *     - pool string the name of the pool that this dedicated IP belongs to
    122:      *     - domain string the domain name (reverse dns) of this dedicated IP
    123:      *     - custom_dns struct information about the ip's custom dns, if it has been configured
    124:      *         - enabled boolean a boolean indicating whether custom dns has been configured for this ip
    125:      *         - valid boolean whether the ip's custom dns is currently valid
    126:      *         - error string if the ip's custom dns is invalid, this will include details about the error
    127:      *     - warmup struct information about the ip's warmup status
    128:      *         - warming_up boolean whether the ip is currently in warmup mode
    129:      *         - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    130:      *         - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    131:      */
    132:     public function setPool($ip, $pool, $create_pool=false) {
    133:         $_params = array("ip" => $ip, "pool" => $pool, "create_pool" => $create_pool);
    134:         return $this->master->call('ips/set-pool', $_params);
    135:     }
    136:
    137:     /**
    138:      * Deletes a dedicated IP. This is permanent and cannot be undone.
    139:      * @param string $ip the dedicated ip to remove from your account
    140:      * @return struct a description of the ip that was removed from your account.
    141:      *     - ip string the ip address
    142:      *     - deleted string a boolean indicating whether the ip was successfully deleted
    143:      */
    144:     public function delete($ip) {
    145:         $_params = array("ip" => $ip);
    146:         return $this->master->call('ips/delete', $_params);
    147:     }
    148:
    149:     /**
    150:      * Lists your dedicated IP pools.
    151:      * @return array the dedicated IP pools for your account, up to a maximum of 1,000
    152:      *     - return[] struct information about each dedicated IP pool
    153:      *         - name string this pool's name
    154:      *         - created_at string the date and time that this pool was created as a UTC timestamp in YYYY-MM-DD HH:MM:SS format
    155:      *         - ips array the dedicated IPs in this pool
    156:      *             - ips[] struct information about each dedicated IP
    157:      *                 - ip string the ip address
    158:      *                 - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
    159:      *                 - pool string the name of the pool that this dedicated IP belongs to
    160:      *                 - domain string the domain name (reverse dns) of this dedicated IP
    161:      *                 - custom_dns struct information about the ip's custom dns, if it has been configured
    162:      *                     - enabled boolean a boolean indicating whether custom dns has been configured for this ip
    163:      *                     - valid boolean whether the ip's custom dns is currently valid
    164:      *                     - error string if the ip's custom dns is invalid, this will include details about the error
    165:      *                 - warmup struct information about the ip's warmup status
    166:      *                     - warming_up boolean whether the ip is currently in warmup mode
    167:      *                     - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    168:      *                     - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    169:      */
    170:     public function listPools() {
    171:         $_params = array();
    172:         return $this->master->call('ips/list-pools', $_params);
    173:     }
    174:
    175:     /**
    176:      * Describes a single dedicated IP pool.
    177:      * @param string $pool a pool name
    178:      * @return struct Information about the dedicated ip pool
    179:      *     - name string this pool's name
    180:      *     - created_at string the date and time that this pool was created as a UTC timestamp in YYYY-MM-DD HH:MM:SS format
    181:      *     - ips array the dedicated IPs in this pool
    182:      *         - ips[] struct information about each dedicated IP
    183:      *             - ip string the ip address
    184:      *             - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
    185:      *             - pool string the name of the pool that this dedicated IP belongs to
    186:      *             - domain string the domain name (reverse dns) of this dedicated IP
    187:      *             - custom_dns struct information about the ip's custom dns, if it has been configured
    188:      *                 - enabled boolean a boolean indicating whether custom dns has been configured for this ip
    189:      *                 - valid boolean whether the ip's custom dns is currently valid
    190:      *                 - error string if the ip's custom dns is invalid, this will include details about the error
    191:      *             - warmup struct information about the ip's warmup status
    192:      *                 - warming_up boolean whether the ip is currently in warmup mode
    193:      *                 - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    194:      *                 - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    195:      */
    196:     public function poolInfo($pool) {
    197:         $_params = array("pool" => $pool);
    198:         return $this->master->call('ips/pool-info', $_params);
    199:     }
    200:
    201:     /**
    202:      * Creates a pool and returns it. If a pool already exists with this
    203: name, no action will be performed.
    204:      * @param string $pool the name of a pool to create
    205:      * @return struct Information about the dedicated ip pool
    206:      *     - name string this pool's name
    207:      *     - created_at string the date and time that this pool was created as a UTC timestamp in YYYY-MM-DD HH:MM:SS format
    208:      *     - ips array the dedicated IPs in this pool
    209:      *         - ips[] struct information about each dedicated IP
    210:      *             - ip string the ip address
    211:      *             - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
    212:      *             - pool string the name of the pool that this dedicated IP belongs to
    213:      *             - domain string the domain name (reverse dns) of this dedicated IP
    214:      *             - custom_dns struct information about the ip's custom dns, if it has been configured
    215:      *                 - enabled boolean a boolean indicating whether custom dns has been configured for this ip
    216:      *                 - valid boolean whether the ip's custom dns is currently valid
    217:      *                 - error string if the ip's custom dns is invalid, this will include details about the error
    218:      *             - warmup struct information about the ip's warmup status
    219:      *                 - warming_up boolean whether the ip is currently in warmup mode
    220:      *                 - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    221:      *                 - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    222:      */
    223:     public function createPool($pool) {
    224:         $_params = array("pool" => $pool);
    225:         return $this->master->call('ips/create-pool', $_params);
    226:     }
    227:
    228:     /**
    229:      * Deletes a pool. A pool must be empty before you can delete it, and you cannot delete your default pool.
    230:      * @param string $pool the name of the pool to delete
    231:      * @return struct information about the status of the pool that was deleted
    232:      *     - pool string the name of the pool
    233:      *     - deleted boolean whether the pool was deleted
    234:      */
    235:     public function deletePool($pool) {
    236:         $_params = array("pool" => $pool);
    237:         return $this->master->call('ips/delete-pool', $_params);
    238:     }
    239:
    240:     /**
    241:      * Tests whether a domain name is valid for use as the custom reverse
    242: DNS for a dedicated IP.
    243:      * @param string $ip a dedicated ip address
    244:      * @param string $domain the domain name to test
    245:      * @return struct validation results for the domain
    246:      *     - valid string whether the domain name has a correctly-configured A record pointing to the ip address
    247:      *     - error string if valid is false, this will contain details about why the domain's A record is incorrect
    248:      */
    249:     public function checkCustomDns($ip, $domain) {
    250:         $_params = array("ip" => $ip, "domain" => $domain);
    251:         return $this->master->call('ips/check-custom-dns', $_params);
    252:     }
    253:
    254:     /**
    255:      * Configures the custom DNS name for a dedicated IP.
    256:      * @param string $ip a dedicated ip address
    257:      * @param string $domain a domain name to set as the dedicated IP's custom dns name.
    258:      * @return struct information about the dedicated IP's new configuration
    259:      *     - ip string the ip address
    260:      *     - created_at string the date and time that the dedicated IP was created as a UTC string in YYYY-MM-DD HH:MM:SS format
    261:      *     - pool string the name of the pool that this dedicated IP belongs to
    262:      *     - domain string the domain name (reverse dns) of this dedicated IP
    263:      *     - custom_dns struct information about the ip's custom dns, if it has been configured
    264:      *         - enabled boolean a boolean indicating whether custom dns has been configured for this ip
    265:      *         - valid boolean whether the ip's custom dns is currently valid
    266:      *         - error string if the ip's custom dns is invalid, this will include details about the error
    267:      *     - warmup struct information about the ip's warmup status
    268:      *         - warming_up boolean whether the ip is currently in warmup mode
    269:      *         - start_at string the start time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    270:      *         - end_at string the end date and time for the warmup process as a UTC string in YYYY-MM-DD HH:MM:SS format
    271:      */
    272:     public function setCustomDns($ip, $domain) {
    273:         $_params = array("ip" => $ip, "domain" => $domain);
    274:         return $this->master->call('ips/set-custom-dns', $_params);
    275:     }
    276:
    277: }
    278:
    279:
    280: