Skip to content

Latest commit

 

History

History
201 lines (134 loc) · 6.68 KB

File metadata and controls

201 lines (134 loc) · 6.68 KB

Hostinger\HostingCronJobsApi

All URIs are relative to https://developers.hostinger.com, except if the operation defines another base path.

Method HTTP request Description
createAccountCronJobV1() POST /api/hosting/v1/accounts/{username}/cron-jobs Create account cron job
deleteAccountCronJobV1() DELETE /api/hosting/v1/accounts/{username}/cron-jobs/{uid} Delete account cron job
getCronJobOutputV1() GET /api/hosting/v1/accounts/{username}/cron-jobs/{uid}/output Get cron job output
listAccountCronJobsV1() GET /api/hosting/v1/accounts/{username}/cron-jobs List account cron jobs

createAccountCronJobV1()

createAccountCronJobV1($username, $hostingV1CronJobsCreateCronJobRequest): \Hostinger\Model\HostingV1CronJobsCronJobResource

Create account cron job

Creates a cron job for the specified account from a schedule expression and a command. Returns the created cron job, including its uid, which is required to delete the cron job or fetch its output.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Bearer authorization: apiToken
$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Hostinger\Api\HostingCronJobsApi(config: $config);
$username = u123456789; // string
$hostingV1CronJobsCreateCronJobRequest = new \Hostinger\Model\HostingV1CronJobsCreateCronJobRequest(); // \Hostinger\Model\HostingV1CronJobsCreateCronJobRequest

try {
    $result = $apiInstance->createAccountCronJobV1($username, $hostingV1CronJobsCreateCronJobRequest);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling HostingCronJobsApi->createAccountCronJobV1: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
username string
hostingV1CronJobsCreateCronJobRequest \Hostinger\Model\HostingV1CronJobsCreateCronJobRequest

Return type

\Hostinger\Model\HostingV1CronJobsCronJobResource

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deleteAccountCronJobV1()

deleteAccountCronJobV1($username, $uid): \Hostinger\Model\CommonSuccessEmptyResource

Delete account cron job

Permanently deletes the cron job identified by its uid. The uid is returned by the list cron jobs endpoint.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Bearer authorization: apiToken
$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Hostinger\Api\HostingCronJobsApi(config: $config);
$username = u123456789; // string
$uid = cron_abc123; // string | Unique identifier of the cron job as returned by the list cron jobs endpoint.

try {
    $result = $apiInstance->deleteAccountCronJobV1($username, $uid);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling HostingCronJobsApi->deleteAccountCronJobV1: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
username string
uid string Unique identifier of the cron job as returned by the list cron jobs endpoint.

Return type

\Hostinger\Model\CommonSuccessEmptyResource

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getCronJobOutputV1()

getCronJobOutputV1($username, $uid): \Hostinger\Model\HostingV1CronJobsCronJobOutputResource

Get cron job output

Returns the output captured from the last execution of the cron job identified by its uid. The uid is returned by the list cron jobs endpoint.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Bearer authorization: apiToken
$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Hostinger\Api\HostingCronJobsApi(config: $config);
$username = u123456789; // string
$uid = cron_abc123; // string | Unique identifier of the cron job as returned by the list cron jobs endpoint.

try {
    $result = $apiInstance->getCronJobOutputV1($username, $uid);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling HostingCronJobsApi->getCronJobOutputV1: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
username string
uid string Unique identifier of the cron job as returned by the list cron jobs endpoint.

Return type

\Hostinger\Model\HostingV1CronJobsCronJobOutputResource

[Back to top] [Back to API list] [Back to Model list] [Back to README]

listAccountCronJobsV1()

listAccountCronJobsV1($username): \Hostinger\Model\HostingV1CronJobsCronJobResource[]

List account cron jobs

Returns the list of cron jobs configured for the specified account, including their schedule and command.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Bearer authorization: apiToken
$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Hostinger\Api\HostingCronJobsApi(config: $config);
$username = u123456789; // string

try {
    $result = $apiInstance->listAccountCronJobsV1($username);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling HostingCronJobsApi->listAccountCronJobsV1: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
username string

Return type

\Hostinger\Model\HostingV1CronJobsCronJobResource[]

[Back to top] [Back to API list] [Back to Model list] [Back to README]