Documentation ¶
Index ¶
- type AvailableMonth
- type Config
- func (ea *Config) GetMonthReportsCSV(month AvailableMonth, reports DownloadOption) *MonthDownloadCSV
- func (ea *Config) GetUsageReports() (*UsageReports, error)
- func (ea *Config) MakeAPIRequestEndpoint(method, endpoint string) (*[]byte, error)
- func (ea *Config) MakeAPIRequestRaw(method, fullURL string) (*[]byte, error)
- type DetailRow
- type DownloadOption
- type MonthDownloadCSV
- type MonthDownloadStructs
- type PriceSheetRow
- type UsageReports
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvailableMonth ¶
type AvailableMonth struct { LinkToDownloadDetailReport string `json:"LinkToDownloadDetailReport"` LinkToDownloadPriceSheetReport string `json:"LinkToDownloadPriceSheetReport"` LinkToDownloadStoreChargeReport string `json:"LinkToDownloadStoreChargeReport"` LinkToDownloadSummaryReport string `json:"LinkToDownloadSummaryReport"` Month string `json:"Month"` }
AvailableMonth is used in UsageReports for the details for a given month
type Config ¶
type Config struct { BaseURI string EA uint32 APIKey string // contains filtered or unexported fields }
Config is the basic config struct for Azure EA billing
var AzureConfig Config
AzureConfig is the global for our configuration
func (*Config) GetMonthReportsCSV ¶
func (ea *Config) GetMonthReportsCSV(month AvailableMonth, reports DownloadOption) *MonthDownloadCSV
GetMonthReportsCSV downloads the reports for a given month from the Azure billing portal, in CSV format. The DownloadOption parameter accepts a number generated by bitwise-or on the avaliable options (see DownloadOption) e.g. DownloadDetail|DownloadPricesheet
func (*Config) GetUsageReports ¶
func (ea *Config) GetUsageReports() (*UsageReports, error)
GetUsageReports returns all of the reports that are present in the EA Billing API. This is usually your first call, as it returns an array of reports in .AvailableMonths, which is required for feeding into GetMonthReportCSV.
func (*Config) MakeAPIRequestEndpoint ¶
MakeAPIRequestEndpoint queries a specific API endpoint, such as "usage-reports", adding the rest of the URL, such as EA number, etc.
type DetailRow ¶
type DetailRow struct { AccountOwnerID string `csv:"AccountOwnerId"` AccountName string `csv:"Account Name"` ServiceAdministratorID string `csv:"ServiceAdministratorId"` SubscriptionID string `csv:"SubscriptionId"` SubscriptionGUID string `csv:"SubscriptionGuid"` SubscriptionName string `csv:"Subscription Name"` DateRaw string `csv:"Date"` Date time.Time `csv:"-"` Month int `csv:"Month"` Day int `csv:"Day"` Year int `csv:"Year"` Product string `csv:"Product"` MeterID string `csv:"Meter ID"` MeterCategory string `csv:"Meter Category"` MeterSubCategory string `csv:"Meter Sub-Category"` MeterRegion string `csv:"Meter Region"` MeterName string `csv:"Meter Name"` ConsumedQuantity float64 `csv:"Consumed Quantity"` ResourceRate float64 `csv:"ResourceRate"` ExtendedCostRaw string `csv:"ExtendedCost"` ResourceLocation string `csv:"Resource Location"` ConsumedService string `csv:"Consumed Service"` InstanceID string `csv:"Instance ID"` ServiceInfo1 string `csv:"ServiceInfo1"` ServiceInfo2 string `csv:"ServiceInfo2"` AdditionalInfo string `csv:"AdditionalInfo"` Tags string `csv:"Tags"` StoreServiceIdentifier string `csv:"Store Service Identifier"` DepartmentName string `csv:"Department Name"` CostCenter string `csv:"Cost Center"` UnitOfMeasure string `csv:"Unit Of Measure"` ResourceGroup string `csv:"Resource Group"` }
DetailRow contains the data of each row in the monthly account detail usage table
type DownloadOption ¶
type DownloadOption int
DownloadOption is used as our enum to toggle which reports we do and don't want to download
const ( // DownloadDetail - Download the detail report DownloadDetail DownloadOption = 1 // DownloadPricesheet - Download the price sheet DownloadPricesheet DownloadOption = 2 // DownloadStoreCharge - Download the store charge DownloadStoreCharge DownloadOption = 4 // DownloadSummary - Download the summary DownloadSummary DownloadOption = 8 // DownloadAll - Download all of the reports DownloadAll DownloadOption = DownloadDetail | DownloadPricesheet | DownloadStoreCharge | DownloadSummary // Download the reports that we have struct support for DownloadForStructs DownloadOption = DownloadDetail | DownloadPricesheet )
type MonthDownloadCSV ¶
type MonthDownloadCSV struct { DetailReport string PriceSheetReport string StoreChargeReport string SummaryReport string }
MonthDownloadCSV is the struct for downloaded reports in CSV format
func (*MonthDownloadCSV) ConvertToStructs ¶
func (reps *MonthDownloadCSV) ConvertToStructs() (*MonthDownloadStructs, error)
ConvertToStructs takes an existing monthly CSV download set and converts it to something more usable
type MonthDownloadStructs ¶
type MonthDownloadStructs struct { DetailReport []*DetailRow PriceSheetReport []*PriceSheetRow }
MonthDownloadStructs is the struct that contains other reports represented as structs
type PriceSheetRow ¶
type PriceSheetRow struct { Service string `csv:"Service"` UnitOfMeasure string `csv:"Unit of Measure"` PartNumber string `csv:"Part Number"` UnitPriceRaw string `csv:"Unit Price"` UnitPrice int `csv:"-"` CommitmentPartNumber string `csv:"Commitment Part Number"` CommitmentUnitPriceRaw string `csv:"Commitment Unit Price"` CommitmentUnitPrice int `csv:"-"` OveragePartNumber string `csv:"Overage Part Number"` OverageUnitPriceRaw string `csv:"Overage Unit Price"` OverageUnitPrice int `csv:"-"` CurrencyCode string `csv:"Currency Code"` }
PriceSheetRow contains the data of each row in a price sheet table
type UsageReports ¶
type UsageReports struct { AvailableMonths []AvailableMonth `json:"AvailableMonths"` ContractVersion string `json:"ContractVersion"` ObjectType string `json:"ObjectType"` }
UsageReports is the struct containing the list of reports avaliable