Class: Zavudev::Resources::Functions
- Inherits:
-
Object
- Object
- Zavudev::Resources::Functions
- Defined in:
- lib/zavudev/resources/functions.rb,
lib/zavudev/resources/functions/secrets.rb
Defined Under Namespace
Classes: Secrets
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(name:, slug:, dependencies: nil, description: nil, http_enabled: nil, memory_mb: nil, runtime: nil, source_code: nil, timeout_sec: nil, request_options: {}) ⇒ Zavudev::Models::FunctionCreateResponse
Create a new Zavu Function.
-
#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, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionDeployResponse
Publish the function.
-
#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.
-
#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::FunctionRetrieveResponse
Get function.
-
#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, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionUpdateResponse
Update the draft source code and/or dependency map without triggering a build.
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.
214 215 216 217 |
# File 'lib/zavudev/resources/functions.rb', line 214 def initialize(client:) @client = client @secrets = Zavudev::Resources::Functions::Secrets.new(client: client) end |
Instance Attribute Details
#secrets ⇒ Zavudev::Resources::Functions::Secrets (readonly)
7 8 9 |
# File 'lib/zavudev/resources/functions.rb', line 7 def secrets @secrets end |
Instance Method Details
#create(name:, slug:, dependencies: nil, description: nil, http_enabled: nil, memory_mb: nil, runtime: nil, source_code: nil, timeout_sec: nil, request_options: {}) ⇒ Zavudev::Models::FunctionCreateResponse
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.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/zavudev/resources/functions.rb', line 41 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.
113 114 115 116 117 118 119 120 |
# File 'lib/zavudev/resources/functions.rb', line 113 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, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionDeployResponse
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`.
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/zavudev/resources/functions.rb', line 140 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.
162 163 164 165 166 167 168 169 |
# File 'lib/zavudev/resources/functions.rb', line 162 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 |
#retrieve(function_id, request_options: {}) ⇒ Zavudev::Models::FunctionRetrieveResponse
Get function
63 64 65 66 67 68 69 70 |
# File 'lib/zavudev/resources/functions.rb', line 63 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 |
#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.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/zavudev/resources/functions.rb', line 194 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, source_code: nil, request_options: {}) ⇒ Zavudev::Models::FunctionUpdateResponse
Update the draft source code and/or dependency map without triggering a build. Visible in the dashboard immediately, but the live (deployed) function does not change until ‘POST /v1/functions/functionId/deploy` runs.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/zavudev/resources/functions.rb', line 89 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 |