pkg/gcv/insight.go (17 lines of code) (raw):
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package gcv
import "time"
// Insight is modeled after the cloud recommender insight.
type Insight struct {
// Name is the name for the insight, this will be of the format:
// projects/<project number>/locations/global/insightTypes/<insight type>/insights/<name>
// <insight type> generally represents the system generating the given insight. <name> corresponds to the
// unique insight generated by the system.
// Example:
// projects/123/locations/global/insightTypes/google.iam.policy.Insight/insights/abcd-1234
Name string `json:"name,omitempty"`
// Description is a human readable summary for the insight.
// Example:
// "Save cost by changing machine type from n1-standard-4 to custom-2-5120."
Description string `json:"description,omitempty"`
// TargetResources is a list of resources that are related to the finding.
// Example:
// ["//cloudresourcemanager.googleapis.com/projectnumbers/123"]
TargetResources []string `json:"target_resources,omitempty"`
// InsightSubtype is the subtype for the given insight.
// Example:
// "Save cost by changing machine type from n1-standard-4 to custom-2-5120."
InsightSubtype string `json:"insight_subtype,omitempty"`
// Content is a free-form field which is be used for storing arbitrary, check-specific data.
Content interface{} `json:"content,omitempty"`
// LastRefreshTime is the timestamp at which the insight was last generated.
// Example:
// "Save cost by changing machine type from n1-standard-4 to custom-2-5120."
LastRefreshTime time.Time `json:"last_refresh_time,omitempty"` //omitted, will be added as part of job param
// ObservationPeriod is the window of data over which the insight was generated, eg if the scanner analyzed the last
// week of data, this value would be 7 days.
ObservationPeriod time.Duration `json:"observation_period,omitempty"` // omitted, will be added as part of job param
// StateInfo describes the state of the Insight. Scanners must not populate this member.
StateInfo StateInfo `json:"state_info,omitempty"`
// Category for the insight, scanners may populate this member.
// One of: COST, SECURITY, PERFORMANCE, MANAGEABILITY
Category string `json:"category,omitempty"`
}
// StateInfo is the state of the data.
type StateInfo struct {
// State is the name of the insight state, one of ACTIVE, ACCEPTED, DISMISSED
State string `json:"state,omitempty"`
// StateMetadata is a user-extensible key-value map for holding arbitrary data.
StateMetadata map[string]string `json:"state_metadata,omitempty"`
}