Class: Zavudev::Resources::Functions::GitLink

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/functions/git_link.rb,
sig/zavudev/resources/functions/git_link.rbs

Instance Method Summary collapse

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.

Parameters:



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.

Parameters:

Returns:

See Also:



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

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.

Parameters:

  • function_id (String) —

    Zavu Function ID.

  • owner (String)
  • repo (String)
  • auto_deploy (Boolean)
  • branch (String)
  • root_dir (String) —

    Subdirectory holding the project, for monorepos.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end

#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::GitLinkRetrieveResponse

The link and its last deploy. Never returns the webhook secret.

Parameters:

Returns:

See Also:



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

Remove the link. The function and its deployments stay. A manual webhook left in the repository stops being accepted, so remove it there too.

Parameters:

Returns:

  • (nil)

See Also:



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.

Parameters:

  • function_id (String) —

    Zavu Function ID.

  • auto_deploy (Boolean)
  • branch (String)
  • root_dir (String, nil)
  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end