billing

package
v7.4.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin

This is an alias to an internal value.

View Source
const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare

This is an alias to an internal value.

View Source
const AuditLogActorTypeUser = shared.AuditLogActorTypeUser

This is an alias to an internal value.

View Source
const CertificateCADigicert = shared.CertificateCADigicert

This is an alias to an internal value.

View Source
const CertificateCAGoogle = shared.CertificateCAGoogle

This is an alias to an internal value.

View Source
const CertificateCALetsEncrypt = shared.CertificateCALetsEncrypt

This is an alias to an internal value.

View Source
const CertificateCASSLCom = shared.CertificateCASSLCom

This is an alias to an internal value.

View Source
const CertificateRequestTypeKeylessCertificate = shared.CertificateRequestTypeKeylessCertificate

This is an alias to an internal value.

View Source
const CertificateRequestTypeOriginECC = shared.CertificateRequestTypeOriginECC

This is an alias to an internal value.

View Source
const CertificateRequestTypeOriginRSA = shared.CertificateRequestTypeOriginRSA

This is an alias to an internal value.

View Source
const CloudflareTunnelConfigSrcCloudflare = shared.CloudflareTunnelConfigSrcCloudflare

This is an alias to an internal value.

View Source
const CloudflareTunnelConfigSrcLocal = shared.CloudflareTunnelConfigSrcLocal

This is an alias to an internal value.

View Source
const CloudflareTunnelStatusDegraded = shared.CloudflareTunnelStatusDegraded

This is an alias to an internal value.

View Source
const CloudflareTunnelStatusDown = shared.CloudflareTunnelStatusDown

This is an alias to an internal value.

View Source
const CloudflareTunnelStatusHealthy = shared.CloudflareTunnelStatusHealthy

This is an alias to an internal value.

View Source
const CloudflareTunnelStatusInactive = shared.CloudflareTunnelStatusInactive

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeMagic = shared.CloudflareTunnelTunTypeMagic

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeWARP = shared.CloudflareTunnelTunTypeWARP

This is an alias to an internal value.

View Source
const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector

This is an alias to an internal value.

View Source
const MemberPoliciesAccessAllow = shared.MemberPoliciesAccessAllow

This is an alias to an internal value.

View Source
const MemberPoliciesAccessDeny = shared.MemberPoliciesAccessDeny

This is an alias to an internal value.

View Source
const MemberStatusAccepted = shared.MemberStatusAccepted

This is an alias to an internal value.

View Source
const MemberStatusPending = shared.MemberStatusPending

This is an alias to an internal value.

View Source
const RatePlanIDBusiness = shared.RatePlanIDBusiness

This is an alias to an internal value.

View Source
const RatePlanIDEnterprise = shared.RatePlanIDEnterprise

This is an alias to an internal value.

View Source
const RatePlanIDFree = shared.RatePlanIDFree

This is an alias to an internal value.

View Source
const RatePlanIDLite = shared.RatePlanIDLite

This is an alias to an internal value.

View Source
const RatePlanIDPartnersBusiness = shared.RatePlanIDPartnersBusiness

This is an alias to an internal value.

View Source
const RatePlanIDPartnersEnterprise = shared.RatePlanIDPartnersEnterprise

This is an alias to an internal value.

View Source
const RatePlanIDPartnersFree = shared.RatePlanIDPartnersFree

This is an alias to an internal value.

View Source
const RatePlanIDPartnersPro = shared.RatePlanIDPartnersPro

This is an alias to an internal value.

View Source
const RatePlanIDPro = shared.RatePlanIDPro

This is an alias to an internal value.

View Source
const RatePlanIDProPlus = shared.RatePlanIDProPlus

This is an alias to an internal value.

View Source
const SortDirectionAsc = shared.SortDirectionAsc

This is an alias to an internal value.

View Source
const SortDirectionDesc = shared.SortDirectionDesc

This is an alias to an internal value.

View Source
const SubscriptionFrequencyMonthly = shared.SubscriptionFrequencyMonthly

This is an alias to an internal value.

View Source
const SubscriptionFrequencyQuarterly = shared.SubscriptionFrequencyQuarterly

This is an alias to an internal value.

View Source
const SubscriptionFrequencyWeekly = shared.SubscriptionFrequencyWeekly

This is an alias to an internal value.

View Source
const SubscriptionFrequencyYearly = shared.SubscriptionFrequencyYearly

This is an alias to an internal value.

View Source
const SubscriptionStateAwaitingPayment = shared.SubscriptionStateAwaitingPayment

This is an alias to an internal value.

View Source
const SubscriptionStateCancelled = shared.SubscriptionStateCancelled

This is an alias to an internal value.

View Source
const SubscriptionStateExpired = shared.SubscriptionStateExpired

This is an alias to an internal value.

View Source
const SubscriptionStateFailed = shared.SubscriptionStateFailed

This is an alias to an internal value.

View Source
const SubscriptionStatePaid = shared.SubscriptionStatePaid

This is an alias to an internal value.

View Source
const SubscriptionStateProvisioned = shared.SubscriptionStateProvisioned

This is an alias to an internal value.

View Source
const SubscriptionStateTrial = shared.SubscriptionStateTrial

This is an alias to an internal value.

View Source
const TokenPolicyEffectAllow = shared.TokenPolicyEffectAllow

This is an alias to an internal value.

View Source
const TokenPolicyEffectDeny = shared.TokenPolicyEffectDeny

This is an alias to an internal value.

View Source
const TokenStatusActive = shared.TokenStatusActive

This is an alias to an internal value.

View Source
const TokenStatusDisabled = shared.TokenStatusDisabled

This is an alias to an internal value.

View Source
const TokenStatusExpired = shared.TokenStatusExpired

This is an alias to an internal value.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASN

type ASN = shared.ASN

This is an alias to an internal type.

type ASNParam

type ASNParam = shared.ASNParam

This is an alias to an internal type.

type AuditLog

type AuditLog = shared.AuditLog

This is an alias to an internal type.

type AuditLogAction

type AuditLogAction = shared.AuditLogAction

This is an alias to an internal type.

type AuditLogActor

type AuditLogActor = shared.AuditLogActor

This is an alias to an internal type.

type AuditLogActorType

type AuditLogActorType = shared.AuditLogActorType

The type of actor, whether a User, Cloudflare Admin, or an Automated System.

This is an alias to an internal type.

type AuditLogOwner

type AuditLogOwner = shared.AuditLogOwner

This is an alias to an internal type.

type AuditLogResource

type AuditLogResource = shared.AuditLogResource

This is an alias to an internal type.

type BillingService

type BillingService struct {
	Options  []option.RequestOption
	Profiles *ProfileService
	Usage    *UsageService
}

BillingService contains methods and other services that help with interacting with the cloudflare API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBillingService method instead.

func NewBillingService

func NewBillingService(opts ...option.RequestOption) (r *BillingService)

NewBillingService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type CertificateCA

type CertificateCA = shared.CertificateCA

The Certificate Authority that will issue the certificate.

This is an alias to an internal type.

type CertificateRequestType

type CertificateRequestType = shared.CertificateRequestType

Signature type desired on certificate ("origin-rsa" (rsa), "origin-ecc" (ecdsa), or "keyless-certificate" (for Keyless SSL servers).

This is an alias to an internal type.

type CloudflareTunnel

type CloudflareTunnel = shared.CloudflareTunnel

A Cloudflare Tunnel that connects your origin to Cloudflare's edge.

This is an alias to an internal type.

type CloudflareTunnelConfigSrc

type CloudflareTunnelConfigSrc = shared.CloudflareTunnelConfigSrc

Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard.

This is an alias to an internal type.

type CloudflareTunnelConnection

type CloudflareTunnelConnection = shared.CloudflareTunnelConnection

This is an alias to an internal type.

type CloudflareTunnelStatus

type CloudflareTunnelStatus = shared.CloudflareTunnelStatus

The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge).

This is an alias to an internal type.

type CloudflareTunnelTunType

type CloudflareTunnelTunType = shared.CloudflareTunnelTunType

The type of tunnel.

This is an alias to an internal type.

type Error

type Error = apierror.Error

type ErrorData

type ErrorData = shared.ErrorData

This is an alias to an internal type.

type ErrorDataSource

type ErrorDataSource = shared.ErrorDataSource

This is an alias to an internal type.

type Member

type Member = shared.Member

This is an alias to an internal type.

type MemberPoliciesAccess

type MemberPoliciesAccess = shared.MemberPoliciesAccess

Allow or deny operations against the resources.

This is an alias to an internal type.

type MemberPoliciesPermissionGroup

type MemberPoliciesPermissionGroup = shared.MemberPoliciesPermissionGroup

A named group of permissions that map to a group of operations against resources.

This is an alias to an internal type.

type MemberPoliciesPermissionGroupsMeta

type MemberPoliciesPermissionGroupsMeta = shared.MemberPoliciesPermissionGroupsMeta

Attributes associated to the permission group.

This is an alias to an internal type.

type MemberPoliciesResourceGroup

type MemberPoliciesResourceGroup = shared.MemberPoliciesResourceGroup

A group of scoped resources.

This is an alias to an internal type.

type MemberPoliciesResourceGroupsMeta

type MemberPoliciesResourceGroupsMeta = shared.MemberPoliciesResourceGroupsMeta

Attributes associated to the resource group.

This is an alias to an internal type.

type MemberPoliciesResourceGroupsScope

type MemberPoliciesResourceGroupsScope = shared.MemberPoliciesResourceGroupsScope

A scope is a combination of scope objects which provides additional context.

This is an alias to an internal type.

type MemberPoliciesResourceGroupsScopeObject

type MemberPoliciesResourceGroupsScopeObject = shared.MemberPoliciesResourceGroupsScopeObject

A scope object represents any resource that can have actions applied against invite.

This is an alias to an internal type.

type MemberPolicy

type MemberPolicy = shared.MemberPolicy

This is an alias to an internal type.

type MemberStatus

type MemberStatus = shared.MemberStatus

A member's status in the account.

This is an alias to an internal type.

type MemberUser

type MemberUser = shared.MemberUser

Details of the user associated to the membership.

This is an alias to an internal type.

type Permission

type Permission = shared.Permission

This is an alias to an internal type.

type PermissionGrant

type PermissionGrant = shared.PermissionGrant

This is an alias to an internal type.

type PermissionGrantParam

type PermissionGrantParam = shared.PermissionGrantParam

This is an alias to an internal type.

type ProfileGetParams

type ProfileGetParams struct {
	// Identifier
	AccountID param.Field[string] `path:"account_id" api:"required"`
}

type ProfileGetResponse

type ProfileGetResponse struct {
	// Billing item identifier tag.
	ID                     string                 `json:"id"`
	AccountType            string                 `json:"account_type"`
	Address                string                 `json:"address"`
	Address2               string                 `json:"address2"`
	Balance                string                 `json:"balance"`
	CardExpiryMonth        int64                  `json:"card_expiry_month"`
	CardExpiryYear         int64                  `json:"card_expiry_year"`
	CardNumber             string                 `json:"card_number"`
	City                   string                 `json:"city"`
	Company                string                 `json:"company"`
	Country                string                 `json:"country"`
	CreatedOn              time.Time              `json:"created_on" format:"date-time"`
	DeviceData             string                 `json:"device_data"`
	EditedOn               time.Time              `json:"edited_on" format:"date-time"`
	EnterpriseBillingEmail string                 `json:"enterprise_billing_email"`
	EnterprisePrimaryEmail string                 `json:"enterprise_primary_email"`
	FirstName              string                 `json:"first_name"`
	IsPartner              bool                   `json:"is_partner"`
	LastName               string                 `json:"last_name"`
	NextBillDate           time.Time              `json:"next_bill_date" format:"date-time"`
	PaymentAddress         string                 `json:"payment_address"`
	PaymentAddress2        string                 `json:"payment_address2"`
	PaymentCity            string                 `json:"payment_city"`
	PaymentCountry         string                 `json:"payment_country"`
	PaymentEmail           string                 `json:"payment_email"`
	PaymentFirstName       string                 `json:"payment_first_name"`
	PaymentGateway         string                 `json:"payment_gateway"`
	PaymentLastName        string                 `json:"payment_last_name"`
	PaymentNonce           string                 `json:"payment_nonce"`
	PaymentState           string                 `json:"payment_state"`
	PaymentZipcode         string                 `json:"payment_zipcode"`
	PrimaryEmail           string                 `json:"primary_email"`
	State                  string                 `json:"state"`
	TaxIDType              string                 `json:"tax_id_type"`
	Telephone              string                 `json:"telephone"`
	UseLegacy              bool                   `json:"use_legacy"`
	ValidationCode         string                 `json:"validation_code"`
	Vat                    string                 `json:"vat"`
	Zipcode                string                 `json:"zipcode"`
	JSON                   profileGetResponseJSON `json:"-"`
}

func (*ProfileGetResponse) UnmarshalJSON

func (r *ProfileGetResponse) UnmarshalJSON(data []byte) (err error)

type ProfileGetResponseEnvelope

type ProfileGetResponseEnvelope struct {
	Errors   []shared.ResponseInfo `json:"errors" api:"required"`
	Messages []shared.ResponseInfo `json:"messages" api:"required"`
	Result   ProfileGetResponse    `json:"result" api:"required"`
	// Whether the API call was successful
	Success ProfileGetResponseEnvelopeSuccess `json:"success" api:"required"`
	JSON    profileGetResponseEnvelopeJSON    `json:"-"`
}

func (*ProfileGetResponseEnvelope) UnmarshalJSON

func (r *ProfileGetResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type ProfileGetResponseEnvelopeSuccess

type ProfileGetResponseEnvelopeSuccess bool

Whether the API call was successful

const (
	ProfileGetResponseEnvelopeSuccessTrue ProfileGetResponseEnvelopeSuccess = true
)

func (ProfileGetResponseEnvelopeSuccess) IsKnown

type ProfileService

type ProfileService struct {
	Options []option.RequestOption
}

ProfileService contains methods and other services that help with interacting with the cloudflare API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewProfileService method instead.

func NewProfileService

func NewProfileService(opts ...option.RequestOption) (r *ProfileService)

NewProfileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ProfileService) Get deprecated

Gets the current billing profile for the account.

Deprecated: deprecated

type RatePlan

type RatePlan = shared.RatePlan

The rate plan applied to the subscription.

This is an alias to an internal type.

type RatePlanID

type RatePlanID = shared.RatePlanID

The ID of the rate plan.

This is an alias to an internal type.

type RatePlanParam

type RatePlanParam = shared.RatePlanParam

The rate plan applied to the subscription.

This is an alias to an internal type.

type ResponseInfo

type ResponseInfo = shared.ResponseInfo

This is an alias to an internal type.

type ResponseInfoSource

type ResponseInfoSource = shared.ResponseInfoSource

This is an alias to an internal type.

type Role

type Role = shared.Role

This is an alias to an internal type.

type RoleParam

type RoleParam = shared.RoleParam

This is an alias to an internal type.

type RolePermissions

type RolePermissions = shared.RolePermissions

This is an alias to an internal type.

type RolePermissionsParam

type RolePermissionsParam = shared.RolePermissionsParam

This is an alias to an internal type.

type SortDirection

type SortDirection = shared.SortDirection

Direction to order DNS records in.

This is an alias to an internal type.

type Subscription

type Subscription = shared.Subscription

This is an alias to an internal type.

type SubscriptionFrequency

type SubscriptionFrequency = shared.SubscriptionFrequency

How often the subscription is renewed automatically.

This is an alias to an internal type.

type SubscriptionParam

type SubscriptionParam = shared.SubscriptionParam

This is an alias to an internal type.

type SubscriptionState

type SubscriptionState = shared.SubscriptionState

The state that the subscription is in.

This is an alias to an internal type.

type Token

type Token = shared.Token

This is an alias to an internal type.

type TokenCondition

type TokenCondition = shared.TokenCondition

This is an alias to an internal type.

type TokenConditionCIDRList

type TokenConditionCIDRList = shared.TokenConditionCIDRList

IPv4/IPv6 CIDR.

This is an alias to an internal type.

type TokenConditionCIDRListParam

type TokenConditionCIDRListParam = shared.TokenConditionCIDRListParam

IPv4/IPv6 CIDR.

This is an alias to an internal type.

type TokenConditionParam

type TokenConditionParam = shared.TokenConditionParam

This is an alias to an internal type.

type TokenConditionRequestIP

type TokenConditionRequestIP = shared.TokenConditionRequestIP

Client IP restrictions.

This is an alias to an internal type.

type TokenConditionRequestIPParam

type TokenConditionRequestIPParam = shared.TokenConditionRequestIPParam

Client IP restrictions.

This is an alias to an internal type.

type TokenParam

type TokenParam = shared.TokenParam

This is an alias to an internal type.

type TokenPolicy

type TokenPolicy = shared.TokenPolicy

This is an alias to an internal type.

type TokenPolicyEffect

type TokenPolicyEffect = shared.TokenPolicyEffect

Allow or deny operations against the resources.

This is an alias to an internal type.

type TokenPolicyParam

type TokenPolicyParam = shared.TokenPolicyParam

This is an alias to an internal type.

type TokenPolicyPermissionGroup

type TokenPolicyPermissionGroup = shared.TokenPolicyPermissionGroup

A named group of permissions that map to a group of operations against resources.

This is an alias to an internal type.

type TokenPolicyPermissionGroupParam

type TokenPolicyPermissionGroupParam = shared.TokenPolicyPermissionGroupParam

A named group of permissions that map to a group of operations against resources.

This is an alias to an internal type.

type TokenPolicyPermissionGroupsMeta

type TokenPolicyPermissionGroupsMeta = shared.TokenPolicyPermissionGroupsMeta

Attributes associated to the permission group.

This is an alias to an internal type.

type TokenPolicyPermissionGroupsMetaParam

type TokenPolicyPermissionGroupsMetaParam = shared.TokenPolicyPermissionGroupsMetaParam

Attributes associated to the permission group.

This is an alias to an internal type.

type TokenPolicyResourcesIAMResourcesTypeObjectNested

type TokenPolicyResourcesIAMResourcesTypeObjectNested = shared.TokenPolicyResourcesIAMResourcesTypeObjectNested

Map of nested resource permissions

This is an alias to an internal type.

type TokenPolicyResourcesIAMResourcesTypeObjectNestedParam

type TokenPolicyResourcesIAMResourcesTypeObjectNestedParam = shared.TokenPolicyResourcesIAMResourcesTypeObjectNestedParam

Map of nested resource permissions

This is an alias to an internal type.

type TokenPolicyResourcesIAMResourcesTypeObjectString

type TokenPolicyResourcesIAMResourcesTypeObjectString = shared.TokenPolicyResourcesIAMResourcesTypeObjectString

Map of simple string resource permissions

This is an alias to an internal type.

type TokenPolicyResourcesIAMResourcesTypeObjectStringParam

type TokenPolicyResourcesIAMResourcesTypeObjectStringParam = shared.TokenPolicyResourcesIAMResourcesTypeObjectStringParam

Map of simple string resource permissions

This is an alias to an internal type.

type TokenPolicyResourcesUnion

type TokenPolicyResourcesUnion = shared.TokenPolicyResourcesUnion

A list of resource names that the policy applies to.

This is an alias to an internal type.

type TokenPolicyResourcesUnionParam

type TokenPolicyResourcesUnionParam = shared.TokenPolicyResourcesUnionParam

A list of resource names that the policy applies to.

This is an alias to an internal type.

type TokenStatus

type TokenStatus = shared.TokenStatus

Status of the token.

This is an alias to an internal type.

type TokenValue

type TokenValue = shared.TokenValue

The token value.

This is an alias to an internal type.

type UsageGetParams added in v7.4.0

type UsageGetParams struct {
	// Represents a Cloudflare resource identifier tag.
	AccountID param.Field[string] `path:"account_id" api:"required"`
	// Start date for the usage query (ISO 8601). Required if `to` is set. When omitted
	// along with `to`, defaults to the start of the current month. Filters by charge
	// period (when consumption happened), not billing period. The maximum date range
	// is 31 days.
	From param.Field[time.Time] `query:"from" format:"date"`
	// Filter results by billable metric id (e.g., workers_standard_requests).
	Metric param.Field[string] `query:"metric"`
	// End date for the usage query (ISO 8601). Required if `from` is set. When omitted
	// along with `from`, defaults to today. Filters by charge period (when consumption
	// happened), not billing period. The maximum date range is 31 days.
	To param.Field[time.Time] `query:"to" format:"date"`
}

func (UsageGetParams) URLQuery added in v7.4.0

func (r UsageGetParams) URLQuery() (v url.Values)

URLQuery serializes UsageGetParams's query parameters as `url.Values`.

type UsageGetResponse added in v7.4.0

type UsageGetResponse struct {
	// Public identifier of the Cloudflare account (account tag).
	BillingAccountID string `json:"BillingAccountId" api:"required"`
	// Display name of the Cloudflare account.
	BillingAccountName string `json:"BillingAccountName" api:"required"`
	// Highest-level classification of a charge based on the nature of how it gets
	// billed. Currently only "Usage" is supported.
	ChargeCategory UsageGetResponseChargeCategory `json:"ChargeCategory" api:"required"`
	// Self-contained summary of the charge's purpose and price.
	ChargeDescription string `json:"ChargeDescription" api:"required"`
	// Indicates how often a charge occurs. Currently only "Usage-Based" is supported.
	ChargeFrequency UsageGetResponseChargeFrequency `json:"ChargeFrequency" api:"required"`
	// Exclusive end of the time interval during which the usage was consumed.
	ChargePeriodEnd time.Time `json:"ChargePeriodEnd" api:"required" format:"date-time"`
	// Inclusive start of the time interval during which the usage was consumed.
	ChargePeriodStart time.Time `json:"ChargePeriodStart" api:"required" format:"date-time"`
	// Measured usage amount within the charge period. Reflects raw metered consumption
	// before pricing transformations.
	ConsumedQuantity float64 `json:"ConsumedQuantity" api:"required"`
	// Unit of measure for the consumed quantity (e.g., "GB", "Requests",
	// "vCPU-Hours").
	ConsumedUnit string `json:"ConsumedUnit" api:"required"`
	// Name of the entity providing the underlying infrastructure or platform.
	HostProviderName string `json:"HostProviderName" api:"required"`
	// Name of the entity responsible for invoicing for the services consumed.
	InvoiceIssuerName string `json:"InvoiceIssuerName" api:"required"`
	// Name of the entity that made the services available for purchase.
	ServiceProviderName string `json:"ServiceProviderName" api:"required"`
	// The display name of the billable metric. Cloudflare extension; replaces FOCUS
	// SkuMeter.
	XBillableMetricName string `json:"x_BillableMetricName" api:"required"`
	// A charge serving as the basis for invoicing, inclusive of all reduced rates and
	// discounts while excluding the amortization of upfront charges (one-time or
	// recurring).
	BilledCost float64 `json:"BilledCost" api:"nullable"`
	// Currency that a charge was billed in (ISO 4217).
	BillingCurrency string `json:"BillingCurrency" api:"nullable"`
	// Exclusive end of the billing cycle that contains this usage record.
	BillingPeriodEnd time.Time `json:"BillingPeriodEnd" api:"nullable" format:"date-time"`
	// Inclusive start of the billing cycle that contains this usage record.
	BillingPeriodStart time.Time `json:"BillingPeriodStart" api:"nullable" format:"date-time"`
	// Indicates whether the row represents a correction to one or more charges
	// invoiced in a previous billing period.
	ChargeClass UsageGetResponseChargeClass `json:"ChargeClass" api:"nullable"`
	// Cost calculated by multiplying ContractedUnitPrice and the corresponding
	// PricingQuantity.
	ContractedCost float64 `json:"ContractedCost" api:"nullable"`
	// The agreed-upon unit price for a single PricingUnit of the associated billable
	// metric, inclusive of negotiated discounts, if present, while excluding any other
	// discounts.
	ContractedUnitPrice float64 `json:"ContractedUnitPrice" api:"nullable"`
	// The amortized cost of the charge after applying all reduced rates, discounts,
	// and the applicable portion of relevant, prepaid purchases (one-time or
	// recurring) that covered the charge.
	EffectiveCost float64 `json:"EffectiveCost" api:"nullable"`
	// Cost calculated by multiplying ListUnitPrice and the corresponding
	// PricingQuantity.
	ListCost float64 `json:"ListCost" api:"nullable"`
	// Suggested provider-published unit price for a single PricingUnit of the
	// associated billable metric, exclusive of any discounts.
	ListUnitPrice float64 `json:"ListUnitPrice" api:"nullable"`
	// Volume of a given service used or purchased, based on the PricingUnit.
	PricingQuantity float64 `json:"PricingQuantity" api:"nullable"`
	// Provider-specified measurement unit for determining unit prices, indicating how
	// the provider rates measured usage after applying pricing rules like block
	// pricing.
	PricingUnit string `json:"PricingUnit" api:"nullable"`
	// Provider-assigned identifier for an isolated geographic area where a service is
	// provided.
	RegionID string `json:"RegionId" api:"nullable"`
	// Name of an isolated geographic area where a service is provided.
	RegionName string `json:"RegionName" api:"nullable"`
	// Unique identifier assigned to a grouping of services. For Cloudflare, this is
	// the subscription or contract ID.
	SubAccountID string `json:"SubAccountId"`
	// Name assigned to a grouping of services. For Cloudflare, this is the
	// subscription or contract display name.
	SubAccountName string `json:"SubAccountName"`
	// The unique identifier for the billable metric in the Cloudflare catalog.
	// Cloudflare extension; replaces FOCUS SkuId.
	XBillableMetricID string `json:"x_BillableMetricId"`
	// The product family the charge belongs to (e.g., "R2", "Workers"). Cloudflare
	// extension; replaces FOCUS ServiceName.
	XProductFamilyName string `json:"x_ProductFamilyName"`
	// The identifier for the Cloudflare zone (zone tag). Cloudflare extension.
	XZoneID string `json:"x_ZoneId" api:"nullable"`
	// The display name of the Cloudflare zone. Cloudflare extension.
	XZoneName string               `json:"x_ZoneName" api:"nullable"`
	JSON      usageGetResponseJSON `json:"-"`
}

A single cost and usage record for a metered product within a specific charge period, aligned with the FinOps FOCUS v1.3 specification.

func (*UsageGetResponse) UnmarshalJSON added in v7.4.0

func (r *UsageGetResponse) UnmarshalJSON(data []byte) (err error)

type UsageGetResponseChargeCategory added in v7.4.0

type UsageGetResponseChargeCategory string

Highest-level classification of a charge based on the nature of how it gets billed. Currently only "Usage" is supported.

const (
	UsageGetResponseChargeCategoryUsage UsageGetResponseChargeCategory = "Usage"
)

func (UsageGetResponseChargeCategory) IsKnown added in v7.4.0

type UsageGetResponseChargeClass added in v7.4.0

type UsageGetResponseChargeClass string

Indicates whether the row represents a correction to one or more charges invoiced in a previous billing period.

const (
	UsageGetResponseChargeClassCorrection UsageGetResponseChargeClass = "Correction"
)

func (UsageGetResponseChargeClass) IsKnown added in v7.4.0

func (r UsageGetResponseChargeClass) IsKnown() bool

type UsageGetResponseChargeFrequency added in v7.4.0

type UsageGetResponseChargeFrequency string

Indicates how often a charge occurs. Currently only "Usage-Based" is supported.

const (
	UsageGetResponseChargeFrequencyUsageBased UsageGetResponseChargeFrequency = "Usage-Based"
)

func (UsageGetResponseChargeFrequency) IsKnown added in v7.4.0

type UsageGetResponseEnvelope added in v7.4.0

type UsageGetResponseEnvelope struct {
	// Contains error details if the request failed.
	Errors []UsageGetResponseEnvelopeErrors `json:"errors" api:"required,nullable"`
	// Contains informational notices about the response.
	Messages []UsageGetResponseEnvelopeMessages `json:"messages" api:"required,nullable"`
	// Contains the array of cost and usage records.
	Result []UsageGetResponse `json:"result" api:"required"`
	// Indicates whether the API call was successful.
	Success UsageGetResponseEnvelopeSuccess `json:"success" api:"required"`
	JSON    usageGetResponseEnvelopeJSON    `json:"-"`
}

Successful response containing an array of FOCUS-aligned cost and usage records.

func (*UsageGetResponseEnvelope) UnmarshalJSON added in v7.4.0

func (r *UsageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type UsageGetResponseEnvelopeErrors added in v7.4.0

type UsageGetResponseEnvelopeErrors struct {
	// Describes the error or notice.
	Message string `json:"message" api:"required"`
	// Identifies the error or notice type.
	Code int64                              `json:"code"`
	JSON usageGetResponseEnvelopeErrorsJSON `json:"-"`
}

Represents an API notice or error detail.

func (*UsageGetResponseEnvelopeErrors) UnmarshalJSON added in v7.4.0

func (r *UsageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error)

type UsageGetResponseEnvelopeMessages added in v7.4.0

type UsageGetResponseEnvelopeMessages struct {
	// Describes the error or notice.
	Message string `json:"message" api:"required"`
	// Identifies the error or notice type.
	Code int64                                `json:"code"`
	JSON usageGetResponseEnvelopeMessagesJSON `json:"-"`
}

Represents an API notice or error detail.

func (*UsageGetResponseEnvelopeMessages) UnmarshalJSON added in v7.4.0

func (r *UsageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error)

type UsageGetResponseEnvelopeSuccess added in v7.4.0

type UsageGetResponseEnvelopeSuccess bool

Indicates whether the API call was successful.

const (
	UsageGetResponseEnvelopeSuccessTrue UsageGetResponseEnvelopeSuccess = true
)

func (UsageGetResponseEnvelopeSuccess) IsKnown added in v7.4.0

type UsagePaygoParams

type UsagePaygoParams struct {
	// Represents a Cloudflare resource identifier tag.
	AccountID param.Field[string] `path:"account_id" api:"required"`
	// Start date for the usage query (ISO 8601).
	From param.Field[time.Time] `query:"from" format:"date"`
	// End date for the usage query (ISO 8601).
	To param.Field[time.Time] `query:"to" format:"date"`
}

func (UsagePaygoParams) URLQuery

func (r UsagePaygoParams) URLQuery() (v url.Values)

URLQuery serializes UsagePaygoParams's query parameters as `url.Values`.

type UsagePaygoResponse

type UsagePaygoResponse struct {
	// Specifies the billing currency code (ISO 4217).
	BillingCurrency string `json:"BillingCurrency" api:"required"`
	// Indicates the start of the billing period.
	BillingPeriodStart time.Time `json:"BillingPeriodStart" api:"required" format:"date-time"`
	// Indicates the end of the charge period.
	ChargePeriodEnd time.Time `json:"ChargePeriodEnd" api:"required" format:"date-time"`
	// Indicates the start of the charge period.
	ChargePeriodStart time.Time `json:"ChargePeriodStart" api:"required" format:"date-time"`
	// Specifies the quantity consumed during this charge period.
	ConsumedQuantity float64 `json:"ConsumedQuantity" api:"required"`
	// A display name for the unit of measurement used for the product (for example,
	// "GB-months", "GB-seconds"). May be empty when the unit is implicit in the
	// service name.
	ConsumedUnit string `json:"ConsumedUnit" api:"required"`
	// Specifies the cost for this charge period in the billing currency.
	ContractedCost float64 `json:"ContractedCost" api:"required"`
	// Specifies the cumulated cost for the billing period in the billing currency.
	CumulatedContractedCost float64 `json:"CumulatedContractedCost" api:"required"`
	// Specifies the cumulated pricing quantity for the billing period.
	CumulatedPricingQuantity int64 `json:"CumulatedPricingQuantity" api:"required"`
	// Specifies the pricing quantity for this charge period.
	PricingQuantity int64 `json:"PricingQuantity" api:"required"`
	// Identifies the Cloudflare service.
	ServiceName string `json:"ServiceName" api:"required"`
	// Identifies the product family for the Cloudflare service.
	ServiceFamilyName string                 `json:"ServiceFamilyName"`
	JSON              usagePaygoResponseJSON `json:"-"`
}

Represents a single billable usage record.

func (*UsagePaygoResponse) UnmarshalJSON

func (r *UsagePaygoResponse) UnmarshalJSON(data []byte) (err error)

type UsagePaygoResponseEnvelope

type UsagePaygoResponseEnvelope struct {
	// Contains error details if the request failed.
	Errors []UsagePaygoResponseEnvelopeErrors `json:"errors" api:"required,nullable"`
	// Contains informational notices about the response.
	Messages []UsagePaygoResponseEnvelopeMessages `json:"messages" api:"required,nullable"`
	// Contains the array of billable usage records.
	Result []UsagePaygoResponse `json:"result" api:"required"`
	// Indicates whether the API call was successful.
	Success UsagePaygoResponseEnvelopeSuccess `json:"success" api:"required"`
	JSON    usagePaygoResponseEnvelopeJSON    `json:"-"`
}

Represents a successful response containing billable usage records.

func (*UsagePaygoResponseEnvelope) UnmarshalJSON

func (r *UsagePaygoResponseEnvelope) UnmarshalJSON(data []byte) (err error)

type UsagePaygoResponseEnvelopeErrors

type UsagePaygoResponseEnvelopeErrors struct {
	// Describes the error or notice.
	Message string `json:"message" api:"required"`
	// Identifies the error or notice type.
	Code int64                                `json:"code"`
	JSON usagePaygoResponseEnvelopeErrorsJSON `json:"-"`
}

Represents an API notice or error detail.

func (*UsagePaygoResponseEnvelopeErrors) UnmarshalJSON

func (r *UsagePaygoResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error)

type UsagePaygoResponseEnvelopeMessages

type UsagePaygoResponseEnvelopeMessages struct {
	// Describes the error or notice.
	Message string `json:"message" api:"required"`
	// Identifies the error or notice type.
	Code int64                                  `json:"code"`
	JSON usagePaygoResponseEnvelopeMessagesJSON `json:"-"`
}

Represents an API notice or error detail.

func (*UsagePaygoResponseEnvelopeMessages) UnmarshalJSON

func (r *UsagePaygoResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error)

type UsagePaygoResponseEnvelopeSuccess

type UsagePaygoResponseEnvelopeSuccess bool

Indicates whether the API call was successful.

const (
	UsagePaygoResponseEnvelopeSuccessTrue UsagePaygoResponseEnvelopeSuccess = true
)

func (UsagePaygoResponseEnvelopeSuccess) IsKnown

type UsageService

type UsageService struct {
	Options []option.RequestOption
}

UsageService contains methods and other services that help with interacting with the cloudflare API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUsageService method instead.

func NewUsageService

func NewUsageService(opts ...option.RequestOption) (r *UsageService)

NewUsageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*UsageService) Get added in v7.4.0

func (r *UsageService) Get(ctx context.Context, params UsageGetParams, opts ...option.RequestOption) (res *[]UsageGetResponse, err error)

Returns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification.

Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost.

**Note:** Cost and pricing fields are not yet populated and will be absent from responses until billing integration is complete.

When `from` and `to` are omitted, defaults to the start of the current month through today. The maximum date range is 31 days.

func (*UsageService) Paygo

func (r *UsageService) Paygo(ctx context.Context, params UsagePaygoParams, opts ...option.RequestOption) (res *[]UsagePaygoResponse, err error)

Returns billable usage data for PayGo (self-serve) accounts. When no query parameters are provided, returns usage for the current billing period. This endpoint is currently in alpha and access is restricted to select accounts. While in alpha, the endpoint may get breaking changes.

Jump to

Keyboard shortcuts

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