mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	api: Add reporting fields to activitylog config endpoint (#20086)
This PR adds the internal reporting state to the `internal/counters/config` read endpoint: * reporting_enabled * billing_start_timestamp
This commit is contained in:
		
							
								
								
									
										4
									
								
								changelog/20086.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								changelog/20086.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | ```release-note:improvement | ||||||
|  | api: `/sys/internal/counters/config` endpoint now contains read-only | ||||||
|  | `reporting_enabled` and `billing_start_timestamp` fields. | ||||||
|  | ``` | ||||||
| @@ -838,6 +838,8 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) { | |||||||
| 			"retention_months":        24, | 			"retention_months":        24, | ||||||
| 			"enabled":                 activityLogEnabledDefaultValue, | 			"enabled":                 activityLogEnabledDefaultValue, | ||||||
| 			"queries_available":       false, | 			"queries_available":       false, | ||||||
|  | 			"reporting_enabled":       core.censusLicensingEnabled, | ||||||
|  | 			"billing_start_timestamp": core.GetBillingStart(), | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 { | 		if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 { | ||||||
| @@ -919,6 +921,8 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) { | |||||||
| 			"retention_months":        2, | 			"retention_months":        2, | ||||||
| 			"enabled":                 "enable", | 			"enabled":                 "enable", | ||||||
| 			"queries_available":       false, | 			"queries_available":       false, | ||||||
|  | 			"reporting_enabled":       false, | ||||||
|  | 			"billing_start_timestamp": core.GetBillingStart(), | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if diff := deep.Equal(resp.Data, expected); len(diff) > 0 { | 		if diff := deep.Equal(resp.Data, expected); len(diff) > 0 { | ||||||
| @@ -955,6 +959,8 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) { | |||||||
| 			"retention_months":        24, | 			"retention_months":        24, | ||||||
| 			"enabled":                 activityLogEnabledDefaultValue, | 			"enabled":                 activityLogEnabledDefaultValue, | ||||||
| 			"queries_available":       false, | 			"queries_available":       false, | ||||||
|  | 			"reporting_enabled":       false, | ||||||
|  | 			"billing_start_timestamp": core.GetBillingStart(), | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 { | 		if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 { | ||||||
|   | |||||||
| @@ -2,5 +2,9 @@ | |||||||
|  |  | ||||||
| package vault | package vault | ||||||
|  |  | ||||||
|  | import "time" | ||||||
|  |  | ||||||
| // CensusAgent is a stub for OSS | // CensusAgent is a stub for OSS | ||||||
| type CensusAgent struct{} | type CensusAgent struct { | ||||||
|  | 	billingStart time.Time | ||||||
|  | } | ||||||
|   | |||||||
| @@ -4015,3 +4015,14 @@ func (c *Core) GetRaftAutopilotState(ctx context.Context) (*raft.AutopilotState, | |||||||
| func (c *Core) Events() *eventbus.EventBus { | func (c *Core) Events() *eventbus.EventBus { | ||||||
| 	return c.events | 	return c.events | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetBillingStart gets the billing start timestamp from the configured Census | ||||||
|  | // Agent, handling a nil agent. | ||||||
|  | func (c *Core) GetBillingStart() time.Time { | ||||||
|  | 	var billingStart time.Time | ||||||
|  | 	if c.censusAgent != nil { | ||||||
|  | 		billingStart = c.censusAgent.billingStart | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return billingStart | ||||||
|  | } | ||||||
|   | |||||||
| @@ -271,6 +271,8 @@ func (b *SystemBackend) handleActivityConfigRead(ctx context.Context, req *logic | |||||||
| 			"retention_months":        config.RetentionMonths, | 			"retention_months":        config.RetentionMonths, | ||||||
| 			"enabled":                 config.Enabled, | 			"enabled":                 config.Enabled, | ||||||
| 			"queries_available":       qa, | 			"queries_available":       qa, | ||||||
|  | 			"reporting_enabled":       b.Core.censusLicensingEnabled, | ||||||
|  | 			"billing_start_timestamp": b.Core.GetBillingStart(), | ||||||
| 		}, | 		}, | ||||||
| 	}, nil | 	}, nil | ||||||
| } | } | ||||||
|   | |||||||
| @@ -924,7 +924,9 @@ $ curl \ | |||||||
|     "default_report_months": 12, |     "default_report_months": 12, | ||||||
|     "enabled": "default-enabled", |     "enabled": "default-enabled", | ||||||
|     "queries_available": true, |     "queries_available": true, | ||||||
|     "retention_months": 24 |     "retention_months": 24, | ||||||
|  |     "reporting_enabled": false, | ||||||
|  |     "billing_start_timestamp": "2022-03-01T00:00:00Z", | ||||||
|   }, |   }, | ||||||
|   "warnings": null |   "warnings": null | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mike Palmiotto
					Mike Palmiotto