Skip to content

Latest commit

 

History

History
727 lines (500 loc) · 26.2 KB

File metadata and controls

727 lines (500 loc) · 26.2 KB

hostinger_api.HostingGitApi

All URIs are relative to https://developers.hostinger.com

Method HTTP request Description
delete_git_auto_deployment_settings_v1 DELETE /api/hosting/v1/accounts/{username}/websites/{domain}/git/auto-deployments/settings Delete Git auto-deployment settings
deploy_website_git_repository_v1 POST /api/hosting/v1/accounts/{username}/websites/{domain}/git/repositories/deploy Deploy website Git repository
generate_git_ssh_key_v1 POST /api/hosting/v1/accounts/{username}/git/ssh-key Generate Git SSH key
get_git_auto_deployment_settings_v1 GET /api/hosting/v1/accounts/{username}/websites/{domain}/git/auto-deployments/settings Get Git auto-deployment settings
get_git_ssh_public_key_v1 GET /api/hosting/v1/accounts/{username}/git/ssh-key Get Git SSH public key
list_git_installation_repositories_v1 GET /api/hosting/v1/git/installations/{uuid}/repositories List Git installation repositories
list_git_installations_v1 GET /api/hosting/v1/git/installations List Git installations
list_website_git_repositories_v1 GET /api/hosting/v1/accounts/{username}/websites/{domain}/git/repositories List website Git repositories
update_git_auto_deployment_settings_v1 PUT /api/hosting/v1/accounts/{username}/websites/{domain}/git/auto-deployments/settings Update Git auto-deployment settings

delete_git_auto_deployment_settings_v1

CommonSuccessEmptyResource delete_git_auto_deployment_settings_v1(username, domain)

Delete Git auto-deployment settings

Removes the Git auto-deployment settings of the website. Files already deployed stay on the website; pushes stop deploying until settings are saved again. Succeeds also when nothing is configured.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.common_success_empty_resource import CommonSuccessEmptyResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 
    domain = 'mydomain.tld' # str | Domain name

    try:
        # Delete Git auto-deployment settings
        api_response = api_instance.delete_git_auto_deployment_settings_v1(username, domain)
        print("The response of HostingGitApi->delete_git_auto_deployment_settings_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->delete_git_auto_deployment_settings_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str
domain str Domain name

Return type

CommonSuccessEmptyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success empty response -
401 Unauthenticated response -
500 Error response -

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

deploy_website_git_repository_v1

HostingV1GitGitDeployOutputResource deploy_website_git_repository_v1(username, domain, hosting_v1_git_deploy_website_git_repository_request)

Deploy website Git repository

Clones a Git repository into a directory of the website, or pulls it again. An empty or missing directory gets a clone of the branch. A directory that already holds this repository and branch is reset to its last commit and pulled: changes made on the server to files the repository tracks are discarded, files it does not track stay. A directory that holds other files, including another repository or another branch of this one, is rejected. composer install runs after the clone or pull when the repository has a composer.json.

The call waits for the deployment and returns its log. is_success false means Git or composer failed and the log says why. A second call for the same directory is rejected while the first is still waiting for the server. If the request times out, the deployment may still finish on the server; calling again later with the same repository and branch pulls.

Private repositories need an SSH URL and the account's Git SSH key from Generate Git SSH key, added to the repository as a deploy key.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_deploy_website_git_repository_request import HostingV1GitDeployWebsiteGitRepositoryRequest
from hostinger_api.models.hosting_v1_git_git_deploy_output_resource import HostingV1GitGitDeployOutputResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 
    domain = 'mydomain.tld' # str | Domain name
    hosting_v1_git_deploy_website_git_repository_request = hostinger_api.HostingV1GitDeployWebsiteGitRepositoryRequest() # HostingV1GitDeployWebsiteGitRepositoryRequest | 

    try:
        # Deploy website Git repository
        api_response = api_instance.deploy_website_git_repository_v1(username, domain, hosting_v1_git_deploy_website_git_repository_request)
        print("The response of HostingGitApi->deploy_website_git_repository_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->deploy_website_git_repository_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str
domain str Domain name
hosting_v1_git_deploy_website_git_repository_request HostingV1GitDeployWebsiteGitRepositoryRequest

Return type

HostingV1GitGitDeployOutputResource

Authorization

apiToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

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

generate_git_ssh_key_v1

HostingV1GitGitSshKeyResource generate_git_ssh_key_v1(username)

Generate Git SSH key

Creates the SSH key pair of the hosting account and returns the public key. When the account already has a key, returns that key unchanged. One key serves every website of the account; add the public key to a private repository as a deploy key before deploying it.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_git_ssh_key_resource import HostingV1GitGitSshKeyResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 

    try:
        # Generate Git SSH key
        api_response = api_instance.generate_git_ssh_key_v1(username)
        print("The response of HostingGitApi->generate_git_ssh_key_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->generate_git_ssh_key_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str

Return type

HostingV1GitGitSshKeyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

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

get_git_auto_deployment_settings_v1

HostingV1GitGitAutoDeploymentSettingsResource get_git_auto_deployment_settings_v1(username, domain)

Get Git auto-deployment settings

Returns the Git auto-deployment settings of the website: which repository and branch deploy into which directory, and whether pushes trigger a deployment. is_enabled false keeps the repository link but ignores pushes.

When the website has no auto-deployment configured every field is null. Save settings with Update Git auto-deployment settings.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_git_auto_deployment_settings_resource import HostingV1GitGitAutoDeploymentSettingsResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 
    domain = 'mydomain.tld' # str | Domain name

    try:
        # Get Git auto-deployment settings
        api_response = api_instance.get_git_auto_deployment_settings_v1(username, domain)
        print("The response of HostingGitApi->get_git_auto_deployment_settings_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->get_git_auto_deployment_settings_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str
domain str Domain name

Return type

HostingV1GitGitAutoDeploymentSettingsResource

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
401 Unauthenticated response -
500 Error response -

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

get_git_ssh_public_key_v1

HostingV1GitGitSshKeyResource get_git_ssh_public_key_v1(username)

Get Git SSH public key

Returns the public SSH key of the hosting account. Deploy website Git repository uses this key to clone and pull over SSH, so a private repository works once the key is added to it as a deploy key on the Git host. public_key is null when the account has no key yet.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_git_ssh_key_resource import HostingV1GitGitSshKeyResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 

    try:
        # Get Git SSH public key
        api_response = api_instance.get_git_ssh_public_key_v1(username)
        print("The response of HostingGitApi->get_git_ssh_public_key_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->get_git_ssh_public_key_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str

Return type

HostingV1GitGitSshKeyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
401 Unauthenticated response -
500 Error response -

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

list_git_installation_repositories_v1

List[HostingV1GitGitRepositoryResource] list_git_installation_repositories_v1(uuid)

List Git installation repositories

Lists the repositories the Git installation can access, read live from the provider. Works for github and gitlab installations. Use an active installation: a suspended or pending one is still queried and the call fails with whatever the provider answers. The list is cut at the first 500 repositories in the order the provider returns them; when the account has more, name the repository directly instead of searching this list.

owner, name and a branch (default_branch or another one) go into source_options of Start Node.js build or into Update Git auto-deployment settings. Returns 404 when the installation does not belong to the customer. Limited to 10 calls per minute per API client (429 above that).

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_git_repository_resource import HostingV1GitGitRepositoryResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    uuid = '018f5e2a-1234-7890-abcd-1234567890ab' # str | Git installation UUID from the List Git installations endpoint

    try:
        # List Git installation repositories
        api_response = api_instance.list_git_installation_repositories_v1(uuid)
        print("The response of HostingGitApi->list_git_installation_repositories_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->list_git_installation_repositories_v1: %s\n" % e)

Parameters

Name Type Description Notes
uuid str Git installation UUID from the List Git installations endpoint

Return type

List[HostingV1GitGitRepositoryResource]

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
404 Error response -
429 Error response -
401 Unauthenticated response -
500 Error response -

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

list_git_installations_v1

List[HostingV1GitGitInstallationResource] list_git_installations_v1(provider=provider, status=status)

List Git installations

Lists the Git provider accounts the customer has connected. Only installations with status active are returned unless the status filter says otherwise.

An empty list means the customer has no active installation. Check status=suspended and status=pending as well. If there is none at all, a Git provider (GitHub or GitLab) has to be connected once in hPanel (Websites, Manage, Advanced, Git; or Add Website, Node.js Web App, Import Git Repository); this endpoint then lists the new installation.

Use uuid as the path parameter of List Git installation repositories, and as installation_uuid in Start Node.js build with source_type git and in Update Git auto-deployment settings.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_git_installation_resource import HostingV1GitGitInstallationResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    provider = 'github' # str | Filter by Git provider (optional)
    status = active # str | Filter by installation status (optional) (default to active)

    try:
        # List Git installations
        api_response = api_instance.list_git_installations_v1(provider=provider, status=status)
        print("The response of HostingGitApi->list_git_installations_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->list_git_installations_v1: %s\n" % e)

Parameters

Name Type Description Notes
provider str Filter by Git provider [optional]
status str Filter by installation status [optional] [default to active]

Return type

List[HostingV1GitGitInstallationResource]

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

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

list_website_git_repositories_v1

List[HostingV1GitWebsiteGitRepositoryResource] list_website_git_repositories_v1(username, domain)

List website Git repositories

Lists the Git repositories linked to directories of the website, with Deploy website Git repository or in the Git section of hPanel: clone URL, branch and directory of each one. A repository whose clone failed stays listed; deploying it again retries the clone. GitHub and GitLab auto-deployments are not listed here; see Get Git auto-deployment settings.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_git_website_git_repository_resource import HostingV1GitWebsiteGitRepositoryResource
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 
    domain = 'mydomain.tld' # str | Domain name

    try:
        # List website Git repositories
        api_response = api_instance.list_website_git_repositories_v1(username, domain)
        print("The response of HostingGitApi->list_website_git_repositories_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->list_website_git_repositories_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str
domain str Domain name

Return type

List[HostingV1GitWebsiteGitRepositoryResource]

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
401 Unauthenticated response -
500 Error response -

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

update_git_auto_deployment_settings_v1

CommonSuccessEmptyResource update_git_auto_deployment_settings_v1(username, domain, hosting_v1_git_update_git_auto_deployment_settings_request)

Update Git auto-deployment settings

Creates or replaces the Git auto-deployment settings of the website: repository, branch, the directory under the document root to deploy into, and is_enabled. Send the full set; is_enabled defaults to true and directory to the document root. installation_uuid must be an installation from List Git installations that belongs to the same customer as the website.

For PHP and static websites, saving with is_enabled true deploys the branch right away and every later push to that branch deploys again. For Node.js and Website Builder websites saving does not clone anything. On a Node.js website start the first deploy with Start Node.js build using source_type git; pushes then trigger new builds with the build settings stored for the website.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.common_success_empty_resource import CommonSuccessEmptyResource
from hostinger_api.models.hosting_v1_git_update_git_auto_deployment_settings_request import HostingV1GitUpdateGitAutoDeploymentSettingsRequest
from hostinger_api.rest import ApiException
from pprint import pprint


# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = hostinger_api.HostingGitApi(api_client)
    username = 'u123456789' # str | 
    domain = 'mydomain.tld' # str | Domain name
    hosting_v1_git_update_git_auto_deployment_settings_request = hostinger_api.HostingV1GitUpdateGitAutoDeploymentSettingsRequest() # HostingV1GitUpdateGitAutoDeploymentSettingsRequest | 

    try:
        # Update Git auto-deployment settings
        api_response = api_instance.update_git_auto_deployment_settings_v1(username, domain, hosting_v1_git_update_git_auto_deployment_settings_request)
        print("The response of HostingGitApi->update_git_auto_deployment_settings_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingGitApi->update_git_auto_deployment_settings_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str
domain str Domain name
hosting_v1_git_update_git_auto_deployment_settings_request HostingV1GitUpdateGitAutoDeploymentSettingsRequest

Return type

CommonSuccessEmptyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success empty response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

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