Class: Vkit::CLI::Commands::ApprovalCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Vkit::CLI::Commands::ApprovalCommand
- Defined in:
- lib/vkit/cli/commands/approval_command.rb
Constant Summary collapse
- DEFAULT_TTL =
3600
Instance Method Summary collapse
- #call_approve(id:, ttl_seconds: DEFAULT_TTL) ⇒ Object
- #call_deny(id:, reason: nil) ⇒ Object
- #call_list(state: "pending") ⇒ Object
Instance Method Details
#call_approve(id:, ttl_seconds: DEFAULT_TTL) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vkit/cli/commands/approval_command.rb', line 42 def call_approve(id:, ttl_seconds: DEFAULT_TTL) with_auth do user = credential_store.user org = user["organization_slug"] res = authenticated_client.post( "/api/v1/orgs/#{org}/approvals/#{id}/approve", body: { ttl_seconds: ttl_seconds } ) puts "✅ Approved request #{id}" puts " → Grant Ref: #{res["grant_ref"] || res["grant_id"]}" puts " → Expires: #{res["expires_at"]}" end end |
#call_deny(id:, reason: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vkit/cli/commands/approval_command.rb', line 58 def call_deny(id:, reason: nil) with_auth do user = credential_store.user org = user["organization_slug"] reason ||= prompt_reason raise "Denial reason cannot be empty" if reason.to_s.empty? authenticated_client.post( "/api/v1/orgs/#{org}/approvals/#{id}/deny", body: { reason: reason } ) puts "🚫 Denied request #{id}" puts " → Reason: #{reason}" end end |
#call_list(state: "pending") ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vkit/cli/commands/approval_command.rb', line 11 def call_list(state: "pending") with_auth do user = credential_store.user org = user["organization_slug"] rows = authenticated_client.get( "/api/v1/orgs/#{org}/approvals?state=#{state}" ) if rows.empty? puts (state) return end puts "📋 Approvals (#{rows.size}, state=#{state})" rows.each do |r| puts "─" * 60 puts "🆔 #{r["id"]}" puts "📂 Dataset: #{r["dataset"]}" puts "📄 Fields: #{Array(r["fields"]).join(', ')}" puts "👤 Requester: #{r["requester_email"]}" puts "🔐 Required: #{r["approver_role"] || 'n/a'}" puts "⚙️ Status: #{r["state"].capitalize}" puts "🔑 Grant Ref: #{r["grant_ref"] || 'n/a'}" if r["state"] == "approved" puts "💬 Reason: #{r["reason"]}" puts "📅 Created: #{r["created_at"]}" end puts "─" * 60 end end |