Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implements (and tests) /account/bandwidth #356

Merged
merged 3 commits into from
Feb 19, 2025
Merged

Conversation

DazWilkin
Copy link
Contributor

Description

Implements for /account/bandwidth to govultr.

The implementation requires a type corresponding to JSON of e.g. this form:

{
	"bandwidth": {
		"previous_month": {
			"timestamp_start": "1735689600",
			"timestamp_end": "1738367999",
			"gb_in": 0,
			"gb_out": 0,
			"total_instance_hours": 1,
			"total_instance_count": 1,
			"instance_bandwidth_credits": 1,
			"free_bandwidth_credits": 2048,
			"purchased_bandwidth_credits": 0,
			"overage": 0,
			"overage_unit_cost": 0.01,
			"overage_cost": 0
		},
		"current_month_to_date": {
			"timestamp_start": "1738368000",
			"timestamp_end": "1739577600",
			"gb_in": 0,
			"gb_out": 0,
			"total_instance_hours": 0,
			"total_instance_count": 0,
			"instance_bandwidth_credits": 0,
			"free_bandwidth_credits": 2048,
			"purchased_bandwidth_credits": 0,
			"overage": 0,
			"overage_unit_cost": 0.01,
			"overage_cost": 0
		},
		"current_month_projected": {
			"timestamp_start": "1738368000",
			"timestamp_end": "1740787199",
			"gb_in": 0,
			"gb_out": 0,
			"total_instance_hours": 0,
			"total_instance_count": 0,
			"instance_bandwidth_credits": 0,
			"free_bandwidth_credits": 2048,
			"purchased_bandwidth_credits": 0,
			"overage": 0,
			"overage_unit_cost": 0.01,
			"overage_cost": 0
		}
	}
}

The type for bandwidth could be represented either a struct or map. A map could promote iterative handling but is less accurate representation of the type.

I've named types AccountBandwidth(Base) and AccountBandwidthPeriod as I was unable to find exemplars elsewhere in the code and Bandwidth is taken (used by Instance) and different.

I've also assumed types (int and float32) for the properties as I was unable to find these types documented elsewhere.

Related Issues

Fixes #354

Checklist:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you linted your code locally prior to submission?
  • Have you successfully ran tests with your changes locally?

Copy link
Member

@optik-aper optik-aper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good other than some style changes. Thanks!

@optik-aper optik-aper added the enhancement New feature or request label Feb 18, 2025
@optik-aper optik-aper self-requested a review February 19, 2025 16:54
Copy link
Member

@optik-aper optik-aper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@optik-aper optik-aper merged commit d756953 into vultr:master Feb 19, 2025
6 checks passed
@optik-aper optik-aper mentioned this pull request Mar 4, 2025
3 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - govultr does not implement GET /account/bandwidth
2 participants