Class: Zavudev::Resources::Functions
- Inherits:
-
Object
- Object
- Zavudev::Resources::Functions
- Defined in:
- lib/zavudev/resources/functions.rb,
lib/zavudev/resources/functions/secrets.rb,
lib/zavudev/resources/functions/git_link.rb,
lib/zavudev/resources/functions/triggers.rb,
sig/zavudev/resources/functions.rbs,
sig/zavudev/resources/functions/secrets.rbs,
sig/zavudev/resources/functions/git_link.rbs,
sig/zavudev/resources/functions/triggers.rbs
Defined Under Namespace
Classes: GitLink, Secrets, Triggers
Instance Attribute Summary collapse
- #git_link ⇒ Zavudev::Resources::Functions::GitLink readonly
- #secrets ⇒ Zavudev::Resources::Functions::Secrets readonly
- #triggers ⇒ Zavudev::Resources::Functions::Triggers readonly
Instance Method Summary collapse
-
#create(name:, slug:, dependencies: nil, description: nil, entrypoint: nil, files: nil, http_enabled: nil, memory_mb: nil, runtime: nil, source_code: nil, timeout_sec: nil, request_options: {}) ⇒ Zavudev::Models::FunctionCreateResponse
Some parameter documentations has been truncated, see Models::FunctionCreateParams for more details.
-
#delete(function_id, request_options: {}) ⇒ Zavudev::Models::FunctionDeleteResponse
Permanently delete a function and cascade: triggers, secrets, deployment history, managed agents+tools, and revoke the auto-provisioned API key.
-
#deploy(function_id, dependencies: nil, entrypoint: nil, files: nil, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionDeployResponse
Some parameter documentations has been truncated, see Models::FunctionDeployParams for more details.
-
#get_deployment(deployment_id, request_options: {}) ⇒ Zavudev::Models::FunctionGetDeploymentResponse
Fetch a deployment to poll its status during a deploy.
-
#initialize(client:) ⇒ Functions
constructor
private
A new instance of Functions.
-
#list_deployments(function_id, limit: nil, request_options: {}) ⇒ Zavudev::Models::FunctionListDeploymentsResponse
List a function's deployment history, newest first.
-
#list_event_types(request_options: {}) ⇒ Zavudev::Models::FunctionListEventTypesResponse
List the event types a function trigger can subscribe to.
-
#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::FunctionRetrieveResponse
Get function.
-
#rollback_deployment(function_id, deployment_id:, request_options: {}) ⇒ Zavudev::Models::FunctionRollbackDeploymentResponse
Re-deploy a previous version by copying its source, dependencies, and runtime pin onto the function's draft, then deploying.
-
#tail_logs(function_id, end_time: nil, filter_pattern: nil, limit: nil, next_token: nil, start_time: nil, request_options: {}) ⇒ Zavudev::Models::FunctionTailLogsResponse
Fetch invocation logs for a function.
-
#update(function_id, dependencies: nil, entrypoint: nil, files: nil, http_enabled: nil, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionUpdateResponse
Some parameter documentations has been truncated, see Models::FunctionUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Functions
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 Functions.
319 320 321 322 323 324 |
# File 'lib/zavudev/resources/functions.rb', line 319 def initialize(client:) @client = client @secrets = Zavudev::Resources::Functions::Secrets.new(client: client) @triggers = Zavudev::Resources::Functions::Triggers.new(client: client) @git_link = Zavudev::Resources::Functions::GitLink.new(client: client) end |
Instance Attribute Details
#git_link ⇒ Zavudev::Resources::Functions::GitLink (readonly)
13 14 15 |
# File 'lib/zavudev/resources/functions.rb', line 13 def git_link @git_link end |
#secrets ⇒ Zavudev::Resources::Functions::Secrets (readonly)
7 8 9 |
# File 'lib/zavudev/resources/functions.rb', line 7 def secrets @secrets end |
#triggers ⇒ Zavudev::Resources::Functions::Triggers (readonly)
10 11 12 |
# File 'lib/zavudev/resources/functions.rb', line 10 def triggers @triggers end |
Instance Method Details
#create(name:, slug:, dependencies: nil, description: nil, entrypoint: nil, files: nil, http_enabled: nil, memory_mb: nil, runtime: nil, source_code: nil, timeout_sec: nil, request_options: {}) ⇒ Zavudev::Models::FunctionCreateResponse
Some parameter documentations has been truncated, see Models::FunctionCreateParams for more details.
Create a new Zavu Function. The function starts in draft status. A dedicated
API key is auto-provisioned and injected as the ZAVU_API_KEY secret so the
function can call back into the Zavu API without manual setup.
Provide sourceCode to seed the draft. Call
POST /v1/functions/{functionId}/deploy afterwards to publish.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zavudev/resources/functions.rb', line 54 def create(params) parsed, = Zavudev::FunctionCreateParams.dump_request(params) @client.request( method: :post, path: "v1/functions", body: parsed, model: Zavudev::Models::FunctionCreateResponse, options: ) end |
#delete(function_id, request_options: {}) ⇒ Zavudev::Models::FunctionDeleteResponse
Permanently delete a function and cascade: triggers, secrets, deployment history, managed agents+tools, and revoke the auto-provisioned API key. The AWS Lambda + log group are torn down asynchronously.
137 138 139 140 141 142 143 144 |
# File 'lib/zavudev/resources/functions.rb', line 137 def delete(function_id, params = {}) @client.request( method: :delete, path: ["v1/functions/%1$s", function_id], model: Zavudev::Models::FunctionDeleteResponse, options: params[:request_options] ) end |
#deploy(function_id, dependencies: nil, entrypoint: nil, files: nil, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionDeployResponse
Some parameter documentations has been truncated, see Models::FunctionDeployParams for more details.
Publish the function. If sourceCode or dependencies are provided in the
body, they replace the current draft before deployment. Returns immediately with
a deployment ID — poll GET /v1/functions/deployments/{deploymentId} until
status is active or failed.
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/zavudev/resources/functions.rb', line 171 def deploy(function_id, params = {}) parsed, = Zavudev::FunctionDeployParams.dump_request(params) @client.request( method: :post, path: ["v1/functions/%1$s/deploy", function_id], body: parsed, model: Zavudev::Models::FunctionDeployResponse, options: ) end |
#get_deployment(deployment_id, request_options: {}) ⇒ Zavudev::Models::FunctionGetDeploymentResponse
Fetch a deployment to poll its status during a deploy.
193 194 195 196 197 198 199 200 |
# File 'lib/zavudev/resources/functions.rb', line 193 def get_deployment(deployment_id, params = {}) @client.request( method: :get, path: ["v1/functions/deployments/%1$s", deployment_id], model: Zavudev::Models::FunctionGetDeploymentResponse, options: params[:request_options] ) end |
#list_deployments(function_id, limit: nil, request_options: {}) ⇒ Zavudev::Models::FunctionListDeploymentsResponse
List a function's deployment history, newest first. Source code is omitted; fetch a single deployment via GET /v1/functions/deployments/deploymentId for full details.
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/zavudev/resources/functions.rb', line 217 def list_deployments(function_id, params = {}) parsed, = Zavudev::FunctionListDeploymentsParams.dump_request(params) query = Zavudev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["v1/functions/%1$s/deployments", function_id], query: query, model: Zavudev::Models::FunctionListDeploymentsResponse, options: ) end |
#list_event_types(request_options: {}) ⇒ Zavudev::Models::FunctionListEventTypesResponse
List the event types a function trigger can subscribe to. Includes the special
type cron, which fires on a schedule (see POST
/v1/functions/functionId/triggers) rather than on a messaging event.
240 241 242 243 244 245 246 247 |
# File 'lib/zavudev/resources/functions.rb', line 240 def list_event_types(params = {}) @client.request( method: :get, path: "v1/functions/event-types", model: Zavudev::Models::FunctionListEventTypesResponse, options: params[:request_options] ) end |
#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::FunctionRetrieveResponse
Get function
76 77 78 79 80 81 82 83 |
# File 'lib/zavudev/resources/functions.rb', line 76 def retrieve(function_id, params = {}) @client.request( method: :get, path: ["v1/functions/%1$s", function_id], model: Zavudev::Models::FunctionRetrieveResponse, options: params[:request_options] ) end |
#rollback_deployment(function_id, deployment_id:, request_options: {}) ⇒ Zavudev::Models::FunctionRollbackDeploymentResponse
Re-deploy a previous version by copying its source, dependencies, and runtime pin onto the function's draft, then deploying. Returns immediately with a deployment ID — poll GET /v1/functions/deployments/deploymentId until status is active or failed. Secrets are not rolled back.
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/zavudev/resources/functions.rb', line 265 def rollback_deployment(function_id, params) parsed, = Zavudev::FunctionRollbackDeploymentParams.dump_request(params) @client.request( method: :post, path: ["v1/functions/%1$s/rollback", function_id], body: parsed, model: Zavudev::Models::FunctionRollbackDeploymentResponse, options: ) end |
#tail_logs(function_id, end_time: nil, filter_pattern: nil, limit: nil, next_token: nil, start_time: nil, request_options: {}) ⇒ Zavudev::Models::FunctionTailLogsResponse
Fetch invocation logs for a function. Logs are paginated via nextToken. Pass
startTime / endTime (Unix epoch milliseconds) to bound the window, or
filterPattern to filter messages.
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/zavudev/resources/functions.rb', line 299 def tail_logs(function_id, params = {}) parsed, = Zavudev::FunctionTailLogsParams.dump_request(params) query = Zavudev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["v1/functions/%1$s/logs", function_id], query: query.transform_keys( end_time: "endTime", filter_pattern: "filterPattern", next_token: "nextToken", start_time: "startTime" ), model: Zavudev::Models::FunctionTailLogsResponse, options: ) end |
#update(function_id, dependencies: nil, entrypoint: nil, files: nil, http_enabled: nil, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionUpdateResponse
Some parameter documentations has been truncated, see Models::FunctionUpdateParams for more details.
Update an existing function. sourceCode / dependencies edit the draft
without triggering a build — they go live on the next
POST /v1/functions/{functionId}/deploy. httpEnabled is applied to the
deployed function immediately, so turning the public endpoint on or off does not
require a redeploy.
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/zavudev/resources/functions.rb', line 113 def update(function_id, params = {}) parsed, = Zavudev::FunctionUpdateParams.dump_request(params) @client.request( method: :patch, path: ["v1/functions/%1$s", function_id], body: parsed, model: Zavudev::Models::FunctionUpdateResponse, options: ) end |