client

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2021 William Perron. All rights reserved. MIT License.

Copyright 2021 William Perron. All rights reserved. MIT License.

Copyright 2021 William Perron. All rights reserved. MIT License.

Copyright 2021 William Perron. All rights reserved. MIT License.

Index

Constants

View Source
const (
	TLSCipherRsa         = "rsa"
	TLSCipherEc          = "ec"
	TLSStrategyAutomatic = "automatic"
	TLSStrategyManual    = "manual"
)

Possible values for the Certificates property of the Domain struct

Variables

This section is empty.

Functions

This section is empty.

Types

type Certificate added in v0.2.1

type Certificate struct {
	Cipher               string `json:"cipher"`
	ProvisioningStrategy string `json:"provisioningStrategy"`
	UpdatedAt            string `json:"updatedAt"`
	CreatedAt            string `json:"createdAt"`
	ExpiresAt            string `json:"expiresAt"`
}

type Client

type Client struct {
	HTTPClient *http.Client
	Token      string
}

Client is a simple wrapper around the std HTTP client used for the Deploy sdk.

func New

func New(token string) *Client

New returns a pointer to a new instance of the Deploy sdk

func (*Client) AddDomain

func (c *Client) AddDomain(projectID string, newDomain Domain) (Domain, error)

AddDomain adds a custom domain name to the project. This is typically followed by the VerifyDomain function

func (*Client) CreateProject

func (c *Client) CreateProject(name string, envVars NewEnvVars) (Project, error)

CreateProject creates a new project with the given name.

func (*Client) CurrentUser

func (c *Client) CurrentUser() (User, error)

CurrentUser returns the currently signed in User, the owner of the Token used by the client sdk.

func (*Client) DeleteDomain

func (c *Client) DeleteDomain(projectID, domainName string) error

DeleteDomain removes a custom domain name associated with a project.

This action only removes the custom domain name resolution on the Deploy side. The DNS records will still have to be removed on the user's registrar.

func (*Client) DeleteProject

func (c *Client) DeleteProject(projectID string) error

DeleteProject deletes a Project and all of its associated Deployments.

func (*Client) GetDeployment

func (c *Client) GetDeployment(projectID string, deploymentID string) (Deployment, error)

GetDeployment returns the information about a given Deployment.

func (*Client) GetDomain

func (c *Client) GetDomain(projectID, domainName string) (Domain, error)

GetDomain returns the information about a given custom domain name.

This is typically used to retrieve the information about the different records that must be created by the user to properly verify the domain.

func (*Client) GetLogs

func (c *Client) GetLogs(projectID string, deploymentID string) (interface{}, error)

GetLogs returns the log lines from a given Deployment

func (*Client) GetProject

func (c *Client) GetProject(projectID string) (Project, error)

GetProject returns the information about a given Project.

func (*Client) LinkProject added in v0.2.0

func (c *Client) LinkProject(req LinkProjectRequest) (Project, error)

func (*Client) ListDeployments

func (c *Client) ListDeployments(projectID string, pageOpts PageOptions) ([]Deployment, PagingInfo, error)

ListDeployments returns a slice of Deployments owned by the current User for a given Project.

func (*Client) ListDomains

func (c *Client) ListDomains(projectID string) ([]Domain, error)

ListDomains returns a list of all the custom domain names associated to the Project.

func (*Client) ListProjects

func (c *Client) ListProjects() ([]Project, error)

ListProjects returns a slice of Projects owned by the current User.

func (*Client) NewProjectDeployment

func (c *Client) NewProjectDeployment(projectID string, depl NewDeploymentRequest) (Deployment, error)

NewProjectDeployment creates a new Deployment for a Project. The URL param is the URL of the source code used for the deployment. The URL needs to be publicly available.

Note that this function is not needed to create a new Deployment for a Project linked to a GitHub repository.

func (*Client) ProvisionCertificateAutomatic added in v0.3.0

func (c *Client) ProvisionCertificateAutomatic(projectID, domainName string) error

ProvisionCertificateAutomatic automatically provisions a valid TLS certificate for a custom domain name.

func (*Client) ProvisionCertificateManual added in v0.3.0

func (c *Client) ProvisionCertificateManual(projectID, domainName string, certificateChain string, privateKey string) error

ProvisionCertificateManual adds a custom TLS certificate for a custom domain name.

func (c *Client) Unlink(projectID string) error

Unlink removes the GitHub integration of a given project.

This only affects future Deployments. Any active Deployment that was created when the GitHub repository was linked will still be active.

func (*Client) UpdateEnvVars

func (c *Client) UpdateEnvVars(projectID string, newVars NewEnvVars) error

UpdateEnvVars overwrites the environment variables of a given Project.

func (*Client) UpdateProject

func (c *Client) UpdateProject(projectID string, newName string) error

UpdateProject modifies an existing Project.

func (*Client) VerifyDomain

func (c *Client) VerifyDomain(projectID, domainName string) error

VerifyDomain sends the signal to Deploy to verify the DNS records for custom domain names. The DNS records must exist prior to starting the verification process. Deploy will not create these for you.

type CommitInfo

type CommitInfo struct {
	Hash                 string `json:"hash"`
	Message              string `json:"message"`
	AuthorName           string `json:"authorName"`
	AuthorEmail          string `json:"authorEmail"`
	AuthorGitHubUsername string `json:"authorGithubUsername,omitempty"`
	URL                  string `json:"url,omitempty"`
}

A CommitInfo is used for Projects linked to a GitHub repository. It contains the information about the commit that triggered a new Deployment for the Project.

type CreateProjectRequest

type CreateProjectRequest struct {
	Name    string     `json:"name"`
	EnvVars NewEnvVars `json:"envVars"`
}

CreateProjectRequest is the expected request body schema for the CreateProject function.

type Deployment

type Deployment struct {
	ID             string          `json:"id"`
	URL            string          `json:"url"`
	DomainMappings []DomainMapping `json:"domainMappings"`
	RelatedCommit  *CommitInfo     `json:"relatedCommit,omitempty"`
	Project        *Project        `json:"project"`
	ProjectID      string          `json:"projectId"`
	EnvVars        EnvVars         `json:"envVars"`
	UpdatedAt      string          `json:"updatedAt"`
	CreatedAt      string          `json:"createdAt"`
}

A Deployment is an immutable version of a Project's source code.

Each Deployment contains a URL to the source code's entrypoint, the auto generated domain name that was created for the Deployment and a copy of the environment variables of the project when the Deployment was created.

If the project is linked to a GitHub repository, it will also contain a CommitInfo containing the summary of the commit.

A Deployment also has a circular reference to a Project. The Project property is only set when accessing the Deployment directly in the API, otherwise it is omitted.

type Domain

type Domain struct {
	Domain               string                `json:"domain"`
	Token                string                `json:"token,omitempty"`
	IsValidated          bool                  `json:"isValidated,omitempty"`
	Certificates         []Certificate         `json:"certificates,omitempty"`
	ProvisioningAttempts []ProvisioningAttempt `json:"provisioningAttempts,omitempty"`
	ProjectID            string                `json:"projectId,omitempty"`
	UpdatedAt            string                `json:"updatedAt,omitempty"`
	CreatedAt            string                `json:"createdAt,omitempty"`
}

A Domain is a custom domain name for a Project.

type DomainMapping

type DomainMapping struct {
	Domain    string `json:"domain"`
	UpdatedAt string `json:"updatedAt"`
	CreatedAt string `json:"createdAt"`
}

A DomainMapping is a simple struct containing to immutable domain name of a Deployment.

type EnvVars

type EnvVars []string

EnvVars is a simple map used to created environment variables in a Project.

type GitHubLink struct {
	Repository Repository `json:"repository"`
	Entrypoint string     `json:"entrypoint"`
	UpdatedAt  string     `json:"updatedAt"`
	CreatedAt  string     `json:"createdAt"`
}

A GitHubLink is used in a Project to link it to a GitHub repository. it contains a Repository struct and an entrypoint corresponding to the source code file used as the entrypoint of the project.

type LinkProjectRequest added in v0.2.0

type LinkProjectRequest struct {
	ProjectID    string `json:"projectId"`
	Organization string `json:"organization"`
	Repo         string `json:"repo"`
	Entrypoint   string `json:"entrypoint"`
}

LinkProjectRequest is the expected request body schema for the LinkProject function.

type NewDeploymentRequest

type NewDeploymentRequest struct {
	URL        string `json:"url"`
	Production bool   `json:"production,omitempty"`
}

NewDeploymentRequest is the expected request body schema for the NewProjectDeployment function.

type NewEnvVars added in v0.3.1

type NewEnvVars map[string]string

NewEnvVars is the expected request body schema for the NewEnvVars function.

type PageOptions

type PageOptions struct {
	Page  int
	Limit int
}

PageOptions defines the parameters used when requesting a paginated resource.

type PagingInfo

type PagingInfo struct {
	Page       int `json:"page"`
	Count      int `json:"count"`
	Limit      int `json:"limit"`
	TotalCount int `json:"totalCount"`
	TotalPages int `json:"totalPages"`
}

PagingInfo is the structure returned by the API for paginated resources.

type Project

type Project struct {
	ID                      string      `json:"id"`
	Name                    string      `json:"name"`
	Git                     *GitHubLink `json:"git,omitempty"`
	ProductionDeployment    *Deployment `json:"productionDeployment,omitempty"`
	HasProductionDeployment bool        `json:"hasProductionDeployment"`
	EnvVars                 EnvVars     `json:"envVars"`
	UpdatedAt               string      `json:"updatedAt"`
	CreatedAt               string      `json:"createdAt"`
}

A Project represents a Deploy project.

Projects can be linked to a public GitHub repository or point directly to a publicly accessible URL. The Project resource contains certain global settings like the name of the project, domain names and environment variables. Projects are made up of Deployments. Every time the source URL is updated or a commit is pushed to the default branch on GitHub, a new Deployment is created and the 'production' deployment is updated.

The ProductionDeployment property is a pointer to the Deployment object that represents the latest version of the project. When a project is first created this value is nil and HasProductionDeployment is set to `false`.

The Git property is only set if the project is linked to a GitHub repository, otherwise it is nil.

A Project also has a circular reference to a Deployment. The Deployment property is only set when accessing the Project directly in the API, otherwise it is omitted.

type ProvisioningAttempt added in v0.2.1

type ProvisioningAttempt struct {
	Domain      string `json:"domain"`
	Cipher      string `json:"cipher"`
	Error       string `json:"error,omitempty"`
	UpdatedAt   string `json:"updatedAt"`
	CreatedAt   string `json:"createdAt"`
	CompletedAt string `json:"completedAt,omitempty"`
}

type Repository

type Repository struct {
	ID    int    `json:"id"`
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

A Repository is a simple structure containing the information identifying the GitHub repository.

type UpdateProjectRequest

type UpdateProjectRequest struct {
	Name string `json:"name"`
}

UpdateProjectRequest is the expected request body schema for the UpdateProject function.

type User

type User struct {
	ID        string    `json:"id"`
	Login     string    `json:"login"`
	Name      string    `json:"name"`
	AvatarURL string    `json:"avatarUrl"`
	GitHubID  int       `json:"githubId"`
	IsAdmin   bool      `json:"isAdmin"`
	IsBlocked bool      `json:"isBlocked"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
}

A User of the Deploy platform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL