Class: Invoance::Resources::Audit::Orgs

Inherits:
Object
  • Object
show all
Defined in:
lib/invoance/resources/audit.rb

Overview

audit.orgs.*

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Orgs

Returns a new instance of Orgs.



99
100
101
# File 'lib/invoance/resources/audit.rb', line 99

def initialize(http)
  @http = http
end

Instance Method Details

#archive(organization_id) ⇒ Object

POST /audit/orgs/:org_id/archive — idempotent. Freezes new activity (ingest/streams/portal/exports return 409 org_archived); history stays verifiable.



125
126
127
# File 'lib/invoance/resources/audit.rb', line 125

def archive(organization_id)
  @http.post("/audit/orgs/#{organization_id}/archive")
end

#create(organization_id:, name: nil) ⇒ Object

POST /audit/orgs



104
105
106
107
108
# File 'lib/invoance/resources/audit.rb', line 104

def create(organization_id:, name: nil)
  body = { "organization_id" => organization_id }
  body["name"] = name if name
  @http.post("/audit/orgs", body)
end

#delete(organization_id) ⇒ Object

DELETE /audit/orgs/:org_id — hard delete, allowed only when nothing signed would be destroyed (never-ingested org, or archived + retention fully purged). Raises ConflictError (org_not_deletable) otherwise.



138
139
140
# File 'lib/invoance/resources/audit.rb', line 138

def delete(organization_id)
  @http.delete("/audit/orgs/#{organization_id}")
end

#integrity(organization_id) ⇒ Object

GET /audit/orgs/:org_id/integrity



143
144
145
# File 'lib/invoance/resources/audit.rb', line 143

def integrity(organization_id)
  @http.get("/audit/orgs/#{organization_id}/integrity")
end

#list(include_archived: nil) ⇒ Object

GET /audit/orgs — archived orgs are excluded unless include_archived: true is passed.



112
113
114
# File 'lib/invoance/resources/audit.rb', line 112

def list(include_archived: nil)
  @http.get("/audit/orgs", { "include_archived" => include_archived })
end

#set_retention(organization_id, days) ⇒ Object

PUT /audit/orgs/:org_id/retention



148
149
150
# File 'lib/invoance/resources/audit.rb', line 148

def set_retention(organization_id, days)
  @http.put("/audit/orgs/#{organization_id}/retention", { "days" => days })
end

#unarchive(organization_id) ⇒ Object

POST /audit/orgs/:org_id/unarchive — idempotent.



130
131
132
# File 'lib/invoance/resources/audit.rb', line 130

def unarchive(organization_id)
  @http.post("/audit/orgs/#{organization_id}/unarchive")
end

#update(organization_id, name:) ⇒ Object

PATCH /audit/orgs/:org_id — rename. Pass name: nil to clear the name (sends JSON null).



118
119
120
# File 'lib/invoance/resources/audit.rb', line 118

def update(organization_id, name:)
  @http.patch("/audit/orgs/#{organization_id}", { "name" => name })
end