Class: Zavudev::Resources::Functions::GitLink
- Inherits:
-
Object
- Object
- Zavudev::Resources::Functions::GitLink
- Defined in:
- lib/zavudev/resources/functions/git_link.rb,
sig/zavudev/resources/functions/git_link.rbs
Instance Method Summary collapse
-
#deploy_now(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkDeployNowResponse
Fetch the linked branch and deploy it without waiting for a push.
-
#initialize(client:) ⇒ GitLink
constructor
private
A new instance of GitLink.
-
#link(function_id, owner:, repo:, auto_deploy: nil, branch: nil, root_dir: nil, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkLinkResponse
Bind a repository to this function so every push to
branchdeploys it. -
#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkRetrieveResponse
The link and its last deploy.
-
#unlink(function_id, request_options: {}) ⇒ nil
Remove the link.
-
#update(function_id, auto_deploy: nil, branch: nil, root_dir: nil, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkUpdateResponse
Change the branch, the root directory, or whether pushes deploy.
Constructor Details
#initialize(client:) ⇒ GitLink
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GitLink.
145 146 147 |
# File 'lib/zavudev/resources/functions/git_link.rb', line 145 def initialize(client:) @client = client end |
Instance Method Details
#deploy_now(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkDeployNowResponse
Fetch the linked branch and deploy it without waiting for a push. Returns
immediately; follow the outcome with GET /v1/functions/{functionId}/git-link,
whose lastStatus and lastError describe the run.
69 70 71 72 73 74 75 76 |
# File 'lib/zavudev/resources/functions/git_link.rb', line 69 def deploy_now(function_id, params = {}) @client.request( method: :post, path: ["v1/functions/%1$s/git-link/deploy", function_id], model: Zavudev::Models::Functions::GitLinkDeployNowResponse, options: params[:request_options] ) end |
#link(function_id, owner:, repo:, auto_deploy: nil, branch: nil, root_dir: nil, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkLinkResponse
Bind a repository to this function so every push to branch deploys it. A
function holds at most one link; linking again returns 400.
The server decides how the link authenticates. If the project has the Zavu
GitHub App installed, the link uses that installation: private repositories work
and there is nothing to configure in the repository. Otherwise it falls back to
a manual link and the response carries a webhookSecret you add to the
repository yourself. connection says which one you got.
The repository is not checked against GitHub here, because it cannot be: an owner/repo that does not exist, or that the installation cannot see, is accepted and fails on the first deploy with a fetch error.
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/zavudev/resources/functions/git_link.rb', line 110 def link(function_id, params) parsed, = Zavudev::Functions::GitLinkLinkParams.dump_request(params) @client.request( method: :post, path: ["v1/functions/%1$s/git-link", function_id], body: parsed, model: Zavudev::Models::Functions::GitLinkLinkResponse, options: ) end |
#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkRetrieveResponse
The link and its last deploy. Never returns the webhook secret.
18 19 20 21 22 23 24 25 |
# File 'lib/zavudev/resources/functions/git_link.rb', line 18 def retrieve(function_id, params = {}) @client.request( method: :get, path: ["v1/functions/%1$s/git-link", function_id], model: Zavudev::Models::Functions::GitLinkRetrieveResponse, options: params[:request_options] ) end |
#unlink(function_id, request_options: {}) ⇒ nil
Remove the link. The function and its deployments stay. A manual webhook left in the repository stops being accepted, so remove it there too.
133 134 135 136 137 138 139 140 |
# File 'lib/zavudev/resources/functions/git_link.rb', line 133 def unlink(function_id, params = {}) @client.request( method: :delete, path: ["v1/functions/%1$s/git-link", function_id], model: NilClass, options: params[:request_options] ) end |
#update(function_id, auto_deploy: nil, branch: nil, root_dir: nil, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkUpdateResponse
Change the branch, the root directory, or whether pushes deploy. Pass at least
one field. rootDir: null clears the subdirectory.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/zavudev/resources/functions/git_link.rb', line 45 def update(function_id, params = {}) parsed, = Zavudev::Functions::GitLinkUpdateParams.dump_request(params) @client.request( method: :patch, path: ["v1/functions/%1$s/git-link", function_id], body: parsed, model: Zavudev::Models::Functions::GitLinkUpdateResponse, options: ) end |