Skip to content

Commit

Permalink
feat: rename get to list functions
Browse files Browse the repository at this point in the history
BREAKING CHANGE: functions that returns a list of objects should use "List" instead of "Get"
  • Loading branch information
amalucelli committed Dec 28, 2022
1 parent 10e51cf commit 6ff8697
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 57 deletions.
14 changes: 7 additions & 7 deletions nextdns/allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type CreateAllowlistRequest struct {
Allowlist []*Allowlist
}

// GetAllowlistRequest encapsulates the request for getting an allowlist.
type GetAllowlistRequest struct {
// ListAllowlistRequest encapsulates the request for getting an allowlist.
type ListAllowlistRequest struct {
ProfileID string
}

Expand All @@ -38,7 +38,7 @@ type UpdateAllowlistRequest struct {
// AllowlistService is an interface for communicating with the NextDNS allowlist API endpoint.
type AllowlistService interface {
Create(context.Context, *CreateAllowlistRequest) error
Get(context.Context, *GetAllowlistRequest) ([]*Allowlist, error)
List(context.Context, *ListAllowlistRequest) ([]*Allowlist, error)
Update(context.Context, *UpdateAllowlistRequest) error
}

Expand Down Expand Up @@ -78,18 +78,18 @@ func (s *allowlistService) Create(ctx context.Context, request *CreateAllowlistR
return nil
}

// Get returns the allowlist of a profile.
func (s *allowlistService) Get(ctx context.Context, request *GetAllowlistRequest) ([]*Allowlist, error) {
// List returns the allowlist of a profile.
func (s *allowlistService) List(ctx context.Context, request *ListAllowlistRequest) ([]*Allowlist, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), allowlistAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the allow list")
return nil, errors.Wrap(err, "error creating request to list the allow list")
}

response := allowlistResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the allow list")
return nil, errors.Wrap(err, "error making a request to list the allow list")
}

return response.Allowlist, nil
Expand Down
2 changes: 1 addition & 1 deletion nextdns/allowlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAllowlistGet(t *testing.T) {

ctx := context.Background()

list, err := client.Allowlist.Get(ctx, &GetAllowlistRequest{
list, err := client.Allowlist.List(ctx, &ListAllowlistRequest{
ProfileID: "abc123",
})
want := []*Allowlist{
Expand Down
14 changes: 7 additions & 7 deletions nextdns/denylist.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type CreateDenylistRequest struct {
Denylist []*Denylist
}

// GetDenylistRequest encapsulates the request for getting a denylist.
type GetDenylistRequest struct {
// ListDenylistRequest encapsulates the request for getting a denylist.
type ListDenylistRequest struct {
ProfileID string
}

Expand All @@ -38,7 +38,7 @@ type UpdateDenylistRequest struct {
// DenylistService is an interface for communicating with the NextDNS denylist API endpoint.
type DenylistService interface {
Create(context.Context, *CreateDenylistRequest) error
Get(context.Context, *GetDenylistRequest) ([]*Denylist, error)
List(context.Context, *ListDenylistRequest) ([]*Denylist, error)
Update(context.Context, *UpdateDenylistRequest) error
}

Expand Down Expand Up @@ -78,18 +78,18 @@ func (s *denylistService) Create(ctx context.Context, request *CreateDenylistReq
return nil
}

// Get returns the denylist of a profile.
func (s *denylistService) Get(ctx context.Context, request *GetDenylistRequest) ([]*Denylist, error) {
// List returns the denylist of a profile.
func (s *denylistService) List(ctx context.Context, request *ListDenylistRequest) ([]*Denylist, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), denylistAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the deny list")
return nil, errors.Wrap(err, "error creating request to list the deny list")
}

response := denylistResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the deny list")
return nil, errors.Wrap(err, "error making a request to list the deny list")
}

return response.Denylist, nil
Expand Down
2 changes: 1 addition & 1 deletion nextdns/denylist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestDenylistGet(t *testing.T) {

ctx := context.Background()

list, err := client.Denylist.Get(ctx, &GetDenylistRequest{
list, err := client.Denylist.List(ctx, &ListDenylistRequest{
ProfileID: "abc123",
})
want := []*Denylist{
Expand Down
14 changes: 7 additions & 7 deletions nextdns/parentalcontrol_categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ type UpdateParentalControlCategoriesRequest struct {
ParentalControlCategories *ParentalControlCategories
}

// GetParentalControlCategoriesRequest encapsulates the request for getting a parental control categories list.
type GetParentalControlCategoriesRequest struct {
// ListParentalControlCategoriesRequest encapsulates the request for getting a parental control categories list.
type ListParentalControlCategoriesRequest struct {
ProfileID string
}

// ParentalControlCategoriesService is an interface for communicating with the NextDNS parental control categories API endpoint.
type ParentalControlCategoriesService interface {
Create(context.Context, *CreateParentalControlCategoriesRequest) error
Get(context.Context, *GetParentalControlCategoriesRequest) ([]*ParentalControlCategories, error)
List(context.Context, *ListParentalControlCategoriesRequest) ([]*ParentalControlCategories, error)
Update(context.Context, *UpdateParentalControlCategoriesRequest) error
}

Expand Down Expand Up @@ -80,18 +80,18 @@ func (s *parentalControlCategoriesService) Create(ctx context.Context, request *
return nil
}

// Get returns a parental control categories list.
func (s *parentalControlCategoriesService) Get(ctx context.Context, request *GetParentalControlCategoriesRequest) ([]*ParentalControlCategories, error) {
// List returns a parental control categories list.
func (s *parentalControlCategoriesService) List(ctx context.Context, request *ListParentalControlCategoriesRequest) ([]*ParentalControlCategories, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), parentalControlCategoriesAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the parental control categories")
return nil, errors.Wrap(err, "error creating request to list the parental control categories")
}

response := parentalControlCategoriesResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the parental control categories")
return nil, errors.Wrap(err, "error making a request to list the parental control categories")
}

return response.ParentalControlCategories, nil
Expand Down
12 changes: 6 additions & 6 deletions nextdns/parentalcontrol_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ type UpdateParentalControlServicesRequest struct {
}

// GetParentalControlServicesRequest encapsulates the request for getting a parental control services list.
type GetParentalControlServicesRequest struct {
type ListParentalControlServicesRequest struct {
ProfileID string
}

// ParentalControlServicesService is an interface for communicating with the NextDNS parental control services API endpoint.
type ParentalControlServicesService interface {
Create(context.Context, *CreateParentalControlServicesRequest) error
Get(context.Context, *GetParentalControlServicesRequest) ([]*ParentalControlServices, error)
List(context.Context, *ListParentalControlServicesRequest) ([]*ParentalControlServices, error)
Update(context.Context, *UpdateParentalControlServicesRequest) error
}

Expand Down Expand Up @@ -80,18 +80,18 @@ func (s *parentalControlServicesService) Create(ctx context.Context, request *Cr
return nil
}

// Get returns a parental control services list.
func (s *parentalControlServicesService) Get(ctx context.Context, request *GetParentalControlServicesRequest) ([]*ParentalControlServices, error) {
// List returns a parental control services list.
func (s *parentalControlServicesService) List(ctx context.Context, request *ListParentalControlServicesRequest) ([]*ParentalControlServices, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), parentalControlServicesAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the parental control services")
return nil, errors.Wrap(err, "error creating request to list the parental control services")
}

response := parentalControlServicesResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the parental control services")
return nil, errors.Wrap(err, "error making a request to list the parental control services")
}

return response.ParentalControlServices, nil
Expand Down
14 changes: 7 additions & 7 deletions nextdns/privacy_blocklists.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ type CreatePrivacyBlocklistsRequest struct {
PrivacyBlocklists []*PrivacyBlocklists
}

// GetPrivacyBlocklistsRequest encapsulates the request for getting the privacy blocklist.
type GetPrivacyBlocklistsRequest struct {
// ListPrivacyBlocklistsRequest encapsulates the request for getting the privacy blocklist.
type ListPrivacyBlocklistsRequest struct {
ProfileID string
}

// PrivacyBlocklistsService is an interface for communicating with the NextDNS privacy blocklist API endpoint.
type PrivacyBlocklistsService interface {
Create(context.Context, *CreatePrivacyBlocklistsRequest) error
Get(context.Context, *GetPrivacyBlocklistsRequest) ([]*PrivacyBlocklists, error)
List(context.Context, *ListPrivacyBlocklistsRequest) ([]*PrivacyBlocklists, error)
}

// privacyBlocklistsResponse represents the NextDNS privacy blocklist service.
Expand Down Expand Up @@ -75,18 +75,18 @@ func (s *privacyBlocklistsService) Create(ctx context.Context, request *CreatePr
return nil
}

// Get returns the privacy blocklist for a profile.
func (s *privacyBlocklistsService) Get(ctx context.Context, request *GetPrivacyBlocklistsRequest) ([]*PrivacyBlocklists, error) {
// List returns the privacy blocklist for a profile.
func (s *privacyBlocklistsService) List(ctx context.Context, request *ListPrivacyBlocklistsRequest) ([]*PrivacyBlocklists, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), privacyBlocklistsAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the privacy blocklist")
return nil, errors.Wrap(err, "error creating request to list the privacy blocklist")
}

response := privacyBlocklistsResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the privacy blocklist")
return nil, errors.Wrap(err, "error making a request to list the privacy blocklist")
}

return response.PrivacyBlocklists, nil
Expand Down
14 changes: 7 additions & 7 deletions nextdns/privacy_natives.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type CreatePrivacyNativesRequest struct {
PrivacyNatives []*PrivacyNatives
}

// GetPrivacyNativesRequest encapsulates the request for getting the privacy native tracking protection list.
type GetPrivacyNativesRequest struct {
// ListPrivacyNativesRequest encapsulates the request for getting the privacy native tracking protection list.
type ListPrivacyNativesRequest struct {
ProfileID string
}

// PrivacyNativesService is an interface for communicating with the NextDNS privacy native tracking protection API endpoint.
type PrivacyNativesService interface {
Create(context.Context, *CreatePrivacyNativesRequest) error
Get(context.Context, *GetPrivacyNativesRequest) ([]*PrivacyNatives, error)
List(context.Context, *ListPrivacyNativesRequest) ([]*PrivacyNatives, error)
}

// privacyNativesResponse represents the NextDNS privacy native tracking protection service.
Expand Down Expand Up @@ -70,18 +70,18 @@ func (s *privacyNativesService) Create(ctx context.Context, request *CreatePriva
return nil
}

// Get returns the privacy native tracking protection list.
func (s *privacyNativesService) Get(ctx context.Context, request *GetPrivacyNativesRequest) ([]*PrivacyNatives, error) {
// List returns the privacy native tracking protection list.
func (s *privacyNativesService) List(ctx context.Context, request *ListPrivacyNativesRequest) ([]*PrivacyNatives, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), privacyNativesAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the privacy native list")
return nil, errors.Wrap(err, "error creating request to list the privacy native list")
}

response := privacyNativesResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the privacy native list")
return nil, errors.Wrap(err, "error making a request to list the privacy native list")
}

return response.PrivacyNatives, nil
Expand Down
14 changes: 7 additions & 7 deletions nextdns/rewrites.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type CreateRewritesRequest struct {
Rewrites *Rewrites
}

// GetRewritesRequest encapsulates the request for getting an rewrites.
type GetRewritesRequest struct {
// ListRewritesRequest encapsulates the request for getting an rewrites.
type ListRewritesRequest struct {
ProfileID string
}

Expand All @@ -39,7 +39,7 @@ type DeleteRewritesRequest struct {
// RewritesService is an interface for communicating with the NextDNS rewrites API endpoint.
type RewritesService interface {
Create(context.Context, *CreateRewritesRequest) (string, error)
Get(context.Context, *GetRewritesRequest) ([]*Rewrites, error)
List(context.Context, *ListRewritesRequest) ([]*Rewrites, error)
Delete(context.Context, *DeleteRewritesRequest) error
}

Expand Down Expand Up @@ -86,18 +86,18 @@ func (s *rewritesService) Create(ctx context.Context, request *CreateRewritesReq
return response.Rewrites.ID, nil
}

// Get returns the rewrites of a profile.
func (s *rewritesService) Get(ctx context.Context, request *GetRewritesRequest) ([]*Rewrites, error) {
// List returns the rewrites of a profile.
func (s *rewritesService) List(ctx context.Context, request *ListRewritesRequest) ([]*Rewrites, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), rewritesAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the rewrite list")
return nil, errors.Wrap(err, "error creating request to list the rewrite list")
}

response := rewritesResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the rewrite list")
return nil, errors.Wrap(err, "error making a request to list the rewrite list")
}

return response.Rewrites, nil
Expand Down
14 changes: 7 additions & 7 deletions nextdns/security_tlds.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type CreateSecurityTldsRequest struct {
SecurityTlds []*SecurityTlds
}

// GetSecurityTldsRequest encapsulates the request for getting a security TLDs list.
type GetSecurityTldsRequest struct {
// ListSecurityTldsRequest encapsulates the request for getting a security TLDs list.
type ListSecurityTldsRequest struct {
ProfileID string
}

// SecurityTldsService is an interface for communicating with the NextDNS security TLDs API endpoint.
type SecurityTldsService interface {
Create(context.Context, *CreateSecurityTldsRequest) error
Get(context.Context, *GetSecurityTldsRequest) ([]*SecurityTlds, error)
List(context.Context, *ListSecurityTldsRequest) ([]*SecurityTlds, error)
}

// securityTldsResponse represents the security TLDs response.
Expand Down Expand Up @@ -70,18 +70,18 @@ func (s *securityTldsService) Create(ctx context.Context, request *CreateSecurit
return nil
}

// Get returns a security TLDs list.
func (s *securityTldsService) Get(ctx context.Context, request *GetSecurityTldsRequest) ([]*SecurityTlds, error) {
// List returns a security TLDs list.
func (s *securityTldsService) List(ctx context.Context, request *ListSecurityTldsRequest) ([]*SecurityTlds, error) {
path := fmt.Sprintf("%s/%s", profileAPIPath(request.ProfileID), securityTldsAPIPath)
req, err := s.client.newRequest(http.MethodGet, path, nil)
if err != nil {
return nil, errors.Wrap(err, "error creating request to get the security tlds list")
return nil, errors.Wrap(err, "error creating request to list the security tlds list")
}

response := securityTldsResponse{}
err = s.client.do(ctx, req, &response)
if err != nil {
return nil, errors.Wrap(err, "error making a request to get the security tlds list")
return nil, errors.Wrap(err, "error making a request to list the security tlds list")
}

return response.SecurityTlds, nil
Expand Down

0 comments on commit 6ff8697

Please sign in to comment.