apiclient

package
v0.10.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAPIKey = errors.New("Invalid API key")

Functions

func ReportCLIError

func ReportCLIError(ctx *config.RunContext, cliErr error, replacePath bool) error

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

func (*APIClient) AddAuthHeaders

func (c *APIClient) AddAuthHeaders(req *http.Request)

func (*APIClient) AddDefaultHeaders

func (c *APIClient) AddDefaultHeaders(req *http.Request)

type APIError

type APIError struct {
	// contains filtered or unexported fields
}

func (*APIError) Error

func (e *APIError) Error() string

type APIErrorResponse

type APIErrorResponse struct {
	Error string `json:"error"`
}

type ActualCostComponent added in v0.10.12

type ActualCostComponent struct {
	UsageType       string
	Description     string
	MonthlyCost     string
	MonthlyQuantity string
	Price           string
	Unit            string
	Currency        string
}

ActualCostComponent represents an individual line item of actual costs for a resource

type ActualCostsQueryVariables added in v0.10.12

type ActualCostsQueryVariables struct {
	RepoURL              string `json:"repoUrl"`
	ProjectWithWorkspace string `json:"project"`
	Address              string `json:"address"`
	Currency             string `json:"currency"`
}

type ActualCostsResult added in v0.10.12

type ActualCostsResult struct {
	Address        string
	ResourceID     string
	StartTimestamp time.Time
	EndTimestamp   time.Time
	CostComponents []ActualCostComponent
}

ActualCostsResult contains the cost information of actual costs retrieved from the Infracost Cloud Usage API

type AddRunResponse added in v0.9.16

type AddRunResponse struct {
	RunID          string `json:"id"`
	ShareURL       string `json:"shareUrl"`
	GuardrailCheck output.GuardrailCheck
}

type AuthClient added in v0.10.3

type AuthClient struct {
	Host string
}

AuthClient represents a client for Infracost's authentication process.

func (AuthClient) Login added in v0.10.3

func (a AuthClient) Login(contextVals map[string]interface{}) (string, string, error)

Login opens a browser with authentication URL and starts a HTTP server to wait for a callback request.

type CloudResourceIDVariables added in v0.10.13

type CloudResourceIDVariables struct {
	RepoURL              string              `json:"repoUrl"`
	ProjectWithWorkspace string              `json:"project"`
	ResourceIDAddresses  []ResourceIDAddress `json:"addressResourceIds"`
}

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	APIKey string `json:"apiKey"`
	Error  string `json:"error"`
}

type DashboardAPIClient

type DashboardAPIClient struct {
	APIClient
}

func NewDashboardAPIClient

func NewDashboardAPIClient(ctx *config.RunContext) *DashboardAPIClient

func (*DashboardAPIClient) AddRun

func (*DashboardAPIClient) QueryCLISettings added in v0.10.7

func (c *DashboardAPIClient) QueryCLISettings() (QueryCLISettingsResponse, error)

type GraphQLQuery

type GraphQLQuery struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables"`
}

type Policy added in v0.10.14

type Policy struct {
	ID                 string          `json:"id"`
	Title              string          `json:"title"`
	Description        string          `json:"description"`
	ResourceType       string          `json:"resource_type"`
	ResourceAttributes json.RawMessage `json:"resource_attributes"`
	Address            string          `json:"address"`
	Suggested          string          `json:"suggested"`
	NoCost             bool            `json:"no_cost"`
}

type PolicyClient added in v0.10.14

type PolicyClient struct {
	// contains filtered or unexported fields
}

PolicyClient wraps the base http.Client with common handling patterns for the Infracost Cloud policy API.

func NewPolicyClient added in v0.10.14

func NewPolicyClient(config *config.Config, logger *logrus.Entry) PolicyClient

NewPolicyClient returns safely initialised PolicyClient.

func (PolicyClient) GetPolicies added in v0.10.14

func (r PolicyClient) GetPolicies(plan []byte) ([]Policy, error)

GetPolicies fetches cost optimization policy from Infracost Cloud.

type PolicyDecisionResponse added in v0.10.14

type PolicyDecisionResponse struct {
	Result []Policy `json:"result"`
}

type PriceQueryKey

type PriceQueryKey struct {
	Resource      *schema.Resource
	CostComponent *schema.CostComponent
}

type PriceQueryResult

type PriceQueryResult struct {
	PriceQueryKey
	Result gjson.Result
}

type PricingAPIClient

type PricingAPIClient struct {
	APIClient
	Currency       string
	EventsDisabled bool
}

func NewPricingAPIClient

func NewPricingAPIClient(ctx *config.RunContext) *PricingAPIClient

func (*PricingAPIClient) AddEvent added in v0.9.5

func (c *PricingAPIClient) AddEvent(name string, env map[string]interface{}) error

func (*PricingAPIClient) RunQueries

func (c *PricingAPIClient) RunQueries(r *schema.Resource) ([]PriceQueryResult, error)

type QueryCLISettingsResponse added in v0.10.7

type QueryCLISettingsResponse struct {
	CloudEnabled       bool `json:"cloudEnabled"`
	ActualCostsEnabled bool `json:"actualCostsEnabled"`
	UsageAPIEnabled    bool `json:"usageApiEnabled"`
}

type ResourceIDAddress added in v0.10.13

type ResourceIDAddress struct {
	Address    string `json:"address"`
	ResourceID string `json:"resourceId"`
}

type UsageAPIClient added in v0.10.12

type UsageAPIClient struct {
	APIClient
	Currency string
}

func NewUsageAPIClient added in v0.10.12

func NewUsageAPIClient(ctx *config.RunContext) *UsageAPIClient

NewUsageAPIClient returns a new Infracost Cloud Usage API Client configured from the RunContext

func (*UsageAPIClient) ListActualCosts added in v0.10.12

func (c *UsageAPIClient) ListActualCosts(vars ActualCostsQueryVariables) ([]ActualCostsResult, error)

ListActualCosts queries the Infracost Cloud Usage API to retrieve any cloud provider reported costs associated with the resource.

func (*UsageAPIClient) ListUsageQuantities added in v0.10.12

func (c *UsageAPIClient) ListUsageQuantities(vars UsageQuantitiesQueryVariables) (map[string]gjson.Result, error)

ListUsageQuantities queries the Infracost Cloud Usage API to retrieve usage estimates derived from cloud provider reported usage and costs.

func (*UsageAPIClient) UploadCloudResourceIDs added in v0.10.13

func (c *UsageAPIClient) UploadCloudResourceIDs(vars CloudResourceIDVariables) error

UploadCloudResourceIDs uploads cloud resource IDs to the Infracost Cloud Usage API, so they may be used to calculate usage estimates.

type UsageQuantitiesQueryVariables added in v0.10.12

type UsageQuantitiesQueryVariables struct {
	RepoURL              string              `json:"repoUrl"`
	ProjectWithWorkspace string              `json:"project"`
	ResourceType         string              `json:"resourceType"`
	Address              string              `json:"address"`
	UsageKeys            []string            `json:"usageKeys"`
	UsageParams          []schema.UsageParam `json:"usageParams"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL