Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unexport client field #168

Merged
merged 5 commits into from Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions iso.go
Expand Up @@ -20,7 +20,7 @@ type ISOService interface {

// ISOServiceHandler handles interaction with the ISO methods for the Vultr API
type ISOServiceHandler struct {
Client *Client
client *Client
}

// ISO represents ISOs currently available on this account.
Expand Down Expand Up @@ -65,13 +65,13 @@ type publicIsosBase struct {
func (i *ISOServiceHandler) Create(ctx context.Context, isoReq *ISOReq) (*ISO, error) {
uri := "/v2/iso"

req, err := i.Client.NewRequest(ctx, http.MethodPost, uri, isoReq)
req, err := i.client.NewRequest(ctx, http.MethodPost, uri, isoReq)
if err != nil {
return nil, err
}

iso := new(isoBase)
if err = i.Client.DoWithContext(ctx, req, iso); err != nil {
if err = i.client.DoWithContext(ctx, req, iso); err != nil {
return nil, err
}

Expand All @@ -82,13 +82,13 @@ func (i *ISOServiceHandler) Create(ctx context.Context, isoReq *ISOReq) (*ISO, e
func (i *ISOServiceHandler) Get(ctx context.Context, isoID string) (*ISO, error) {
uri := fmt.Sprintf("/v2/iso/%s", isoID)

req, err := i.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
}

iso := new(isoBase)
if err := i.Client.DoWithContext(ctx, req, iso); err != nil {
if err := i.client.DoWithContext(ctx, req, iso); err != nil {
return nil, err
}
return iso.ISO, nil
Expand All @@ -98,19 +98,19 @@ func (i *ISOServiceHandler) Get(ctx context.Context, isoID string) (*ISO, error)
func (i *ISOServiceHandler) Delete(ctx context.Context, isoID string) error {
uri := fmt.Sprintf("/v2/iso/%s", isoID)

req, err := i.Client.NewRequest(ctx, http.MethodDelete, uri, nil)
req, err := i.client.NewRequest(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
}

return i.Client.DoWithContext(ctx, req, nil)
return i.client.DoWithContext(ctx, req, nil)
}

// List will list all ISOs currently available on your account
func (i *ISOServiceHandler) List(ctx context.Context, options *ListOptions) ([]ISO, *Meta, error) {
uri := "/v2/iso"

req, err := i.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}
Expand All @@ -123,7 +123,7 @@ func (i *ISOServiceHandler) List(ctx context.Context, options *ListOptions) ([]I
req.URL.RawQuery = newValues.Encode()

iso := new(isosBase)
if err = i.Client.DoWithContext(ctx, req, iso); err != nil {
if err = i.client.DoWithContext(ctx, req, iso); err != nil {
return nil, nil, err
}

Expand All @@ -134,7 +134,7 @@ func (i *ISOServiceHandler) List(ctx context.Context, options *ListOptions) ([]I
func (i *ISOServiceHandler) ListPublic(ctx context.Context, options *ListOptions) ([]PublicISO, *Meta, error) {
uri := "/v2/iso-public"

req, err := i.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}
Expand All @@ -147,7 +147,7 @@ func (i *ISOServiceHandler) ListPublic(ctx context.Context, options *ListOptions
req.URL.RawQuery = newValues.Encode()

iso := new(publicIsosBase)
if err = i.Client.DoWithContext(ctx, req, iso); err != nil {
if err = i.client.DoWithContext(ctx, req, iso); err != nil {
return nil, nil, err
}

Expand Down
10 changes: 5 additions & 5 deletions plans.go
Expand Up @@ -16,7 +16,7 @@ type PlanService interface {

// PlanServiceHandler handles interaction with the Plans methods for the Vultr API
type PlanServiceHandler struct {
Client *Client
client *Client
}

// BareMetalPlan represents bare metal plans
Expand Down Expand Up @@ -62,7 +62,7 @@ type bareMetalPlansBase struct {
func (p *PlanServiceHandler) List(ctx context.Context, planType string, options *ListOptions) ([]Plan, *Meta, error) {
uri := "/v2/plans"

req, err := p.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := p.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}
Expand All @@ -79,7 +79,7 @@ func (p *PlanServiceHandler) List(ctx context.Context, planType string, options
req.URL.RawQuery = newValues.Encode()

plans := new(plansBase)
if err = p.Client.DoWithContext(ctx, req, plans); err != nil {
if err = p.client.DoWithContext(ctx, req, plans); err != nil {
return nil, nil, err
}

Expand All @@ -90,7 +90,7 @@ func (p *PlanServiceHandler) List(ctx context.Context, planType string, options
func (p *PlanServiceHandler) ListBareMetal(ctx context.Context, options *ListOptions) ([]BareMetalPlan, *Meta, error) {
uri := "/v2/plans-metal"

req, err := p.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := p.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}
Expand All @@ -103,7 +103,7 @@ func (p *PlanServiceHandler) ListBareMetal(ctx context.Context, options *ListOpt
req.URL.RawQuery = newValues.Encode()

bmPlans := new(bareMetalPlansBase)
if err = p.Client.DoWithContext(ctx, req, bmPlans); err != nil {
if err = p.client.DoWithContext(ctx, req, bmPlans); err != nil {
return nil, nil, err
}

Expand Down
10 changes: 5 additions & 5 deletions regions.go
Expand Up @@ -19,7 +19,7 @@ var _ RegionService = &RegionServiceHandler{}

// RegionServiceHandler handles interaction with the region methods for the Vultr API
type RegionServiceHandler struct {
Client *Client
client *Client
}

// Region represents a Vultr region
Expand All @@ -45,7 +45,7 @@ type PlanAvailability struct {
func (r *RegionServiceHandler) List(ctx context.Context, options *ListOptions) ([]Region, *Meta, error) {
uri := "/v2/regions"

req, err := r.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := r.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}
Expand All @@ -58,7 +58,7 @@ func (r *RegionServiceHandler) List(ctx context.Context, options *ListOptions) (
req.URL.RawQuery = newValues.Encode()

regions := new(regionBase)
if err = r.Client.DoWithContext(ctx, req, &regions); err != nil {
if err = r.client.DoWithContext(ctx, req, &regions); err != nil {
return nil, nil, err
}

Expand All @@ -69,7 +69,7 @@ func (r *RegionServiceHandler) List(ctx context.Context, options *ListOptions) (
func (r *RegionServiceHandler) Availability(ctx context.Context, regionID string, planType string) (*PlanAvailability, error) {
uri := fmt.Sprintf("/v2/regions/%s/availability", regionID)

req, err := r.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := r.client.NewRequest(ctx, http.MethodGet, uri, nil)

if err != nil {
return nil, err
Expand All @@ -83,7 +83,7 @@ func (r *RegionServiceHandler) Availability(ctx context.Context, regionID string
}

plans := new(PlanAvailability)
if err = r.Client.DoWithContext(ctx, req, plans); err != nil {
if err = r.client.DoWithContext(ctx, req, plans); err != nil {
return nil, err
}

Expand Down
22 changes: 11 additions & 11 deletions snapshot.go
Expand Up @@ -20,7 +20,7 @@ type SnapshotService interface {

// SnapshotServiceHandler handles interaction with the snapshot methods for the Vultr API
type SnapshotServiceHandler struct {
Client *Client
client *Client
}

// Snapshot represents a Vultr snapshot
Expand Down Expand Up @@ -59,13 +59,13 @@ type snapshotBase struct {
func (s *SnapshotServiceHandler) Create(ctx context.Context, snapshotReq *SnapshotReq) (*Snapshot, error) {
uri := "/v2/snapshots"

req, err := s.Client.NewRequest(ctx, http.MethodPost, uri, snapshotReq)
req, err := s.client.NewRequest(ctx, http.MethodPost, uri, snapshotReq)
if err != nil {
return nil, err
}

snapshot := new(snapshotBase)
if err = s.Client.DoWithContext(ctx, req, snapshot); err != nil {
if err = s.client.DoWithContext(ctx, req, snapshot); err != nil {
return nil, err
}

Expand All @@ -76,13 +76,13 @@ func (s *SnapshotServiceHandler) Create(ctx context.Context, snapshotReq *Snapsh
func (s *SnapshotServiceHandler) CreateFromURL(ctx context.Context, snapshotURLReq *SnapshotURLReq) (*Snapshot, error) {
uri := "/v2/snapshots/create-from-url"

req, err := s.Client.NewRequest(ctx, http.MethodPost, uri, snapshotURLReq)
req, err := s.client.NewRequest(ctx, http.MethodPost, uri, snapshotURLReq)
if err != nil {
return nil, err
}

snapshot := new(snapshotBase)
if err = s.Client.DoWithContext(ctx, req, snapshot); err != nil {
if err = s.client.DoWithContext(ctx, req, snapshot); err != nil {
return nil, err
}

Expand All @@ -93,13 +93,13 @@ func (s *SnapshotServiceHandler) CreateFromURL(ctx context.Context, snapshotURLR
func (s *SnapshotServiceHandler) Get(ctx context.Context, snapshotID string) (*Snapshot, error) {
uri := fmt.Sprintf("/v2/snapshots/%s", snapshotID)

req, err := s.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := s.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
}

snapshot := new(snapshotBase)
if err = s.Client.DoWithContext(ctx, req, snapshot); err != nil {
if err = s.client.DoWithContext(ctx, req, snapshot); err != nil {
return nil, err
}

Expand All @@ -110,19 +110,19 @@ func (s *SnapshotServiceHandler) Get(ctx context.Context, snapshotID string) (*S
func (s *SnapshotServiceHandler) Delete(ctx context.Context, snapshotID string) error {
uri := fmt.Sprintf("/v2/snapshots/%s", snapshotID)

req, err := s.Client.NewRequest(ctx, http.MethodDelete, uri, nil)
req, err := s.client.NewRequest(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
}

return s.Client.DoWithContext(ctx, req, nil)
return s.client.DoWithContext(ctx, req, nil)
}

// List all available snapshots.
func (s *SnapshotServiceHandler) List(ctx context.Context, options *ListOptions) ([]Snapshot, *Meta, error) {
uri := "/v2/snapshots"

req, err := s.Client.NewRequest(ctx, http.MethodGet, uri, nil)
req, err := s.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, nil, err
}
Expand All @@ -134,7 +134,7 @@ func (s *SnapshotServiceHandler) List(ctx context.Context, options *ListOptions)
req.URL.RawQuery = newValues.Encode()

snapshots := new(snapshotsBase)
if err = s.Client.DoWithContext(ctx, req, snapshots); err != nil {
if err = s.client.DoWithContext(ctx, req, snapshots); err != nil {
return nil, nil, err
}

Expand Down