Skip to content

Commit

Permalink
Small documentation and naming fixes (#71)
Browse files Browse the repository at this point in the history
Fix some inline documentation, rename request.go, request_test.go to
requests.go, requests_test.go.
  • Loading branch information
ozerovandrei authored Apr 22, 2018
1 parent cd54bd1 commit d1d4436
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 46 deletions.
2 changes: 1 addition & 1 deletion selvpcclient/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ You need to initialize the needed service client prior to do any requests:
resellClient := resell.NewV2ResellClient(token)
All methods of service clients uses the Go context to provide end-user of the
library with a native way to work with the cancelation signals
library with a native way to work with the cancellation signals
*/
package selvpcclient
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewV2ResellClient(tokenID string) *selvpcclient.ServiceClient {
return resellClient
}

// NewV2ResellClientWithEndpoint initializes a new Resell client for the V2 API with custom endpoint.
// NewV2ResellClientWithEndpoint initializes a new Resell client for the V2 API with a custom endpoint.
func NewV2ResellClientWithEndpoint(tokenID, endpoint string) *selvpcclient.ServiceClient {
resellClient := &selvpcclient.ServiceClient{
HTTPClient: &http.Client{},
Expand Down
6 changes: 3 additions & 3 deletions selvpcclient/resell/v2/floatingips/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ the Resell v2 API.
Example of getting a single floating ip referenced by its id
floatingip, _, err := floatingips.Get(context, resellClient, fipID)
floatingIP, _, err := floatingips.Get(context, resellClient, fipID)
if err != nil {
log.Fatal(err)
}
fmt.Println(floatingip)
fmt.Println(floatingIP)
Example of getting all floating ips
Expand Down Expand Up @@ -36,7 +36,7 @@ Example of creating floating ips in a project
log.Fatal(err)
}
for _, newFloatingIP := range newFloatingIPs {
fmt.Printf("%v\n", newFloatingIP)
fmt.Println(newFloatingIPs)
}
Example of deleting a single floating ip
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package floatingips

// FloatingIPOpts represents options for the floatingips Create request.
// FloatingIPOpts represents options for the floating ips Create request.
type FloatingIPOpts struct {
// FloatingIPs represents options for all floatingips.
// FloatingIPs represents options for all floating ips.
FloatingIPs []FloatingIPOpt `json:"floatingips"`
}

// FloatingIPOpt represents options for the single floating ip.
type FloatingIPOpt struct {
// Region represents a region of where the floating ips should reside.
// Region represents an Identity service region of where the floating ips should reside.
Region string `json:"region"`

// Quantity represents how many floating ips do we need to create.
// Quantity represents how many floating ips do we need to create in a single request.
Quantity int `json:"quantity"`
}
6 changes: 3 additions & 3 deletions selvpcclient/resell/v2/floatingips/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ type FloatingIP struct {
// ID is a unique id of the floating ip.
ID string `json:"id"`

// ProjectID represents an associated Resell project.
// ProjectID represents an associated Identity service project.
ProjectID string `json:"project_id"`

// PortID contains an uuid of the port to which floating ip is associated to.
// PortID contains a Networking service uuid of the port to which floating ip is associated to.
PortID string `json:"port_id"`

// FixedIPAddress contains an IP address of the port to which floating ip is
// associated to.
FixedIPAddress string `json:"fixed_ip_address"`

// Region represents a region of where the floating ip resides.
// Region represents an Identity service region of where the floating ip resides.
Region string `json:"region"`

// Status represents a current status of the floating ip.
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/licenses/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Example of creating licenses in a project
},
}
projectID := "49338ac045f448e294b25d013f890317"
newLicenses, _, err := floatingips.Create(ctx, resellClient, projectID, newLicensesOptions)
newLicenses, _, err := licenses.Create(ctx, resellClient, projectID, newLicensesOptions)
if err != nil {
log.Fatal(err)
}
for _, newLicense := range newLicenses {
fmt.Printf("%v\n", newLicense)
}
Example of deleting a single floating ip
Example of deleting a single license
_, err = licenses.Delete(ctx, resellClient, "5232d5f3-4950-454b-bd41-78c5295622cd")
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ type LicenseOpts struct {

// LicenseOpt represents options for the single license.
type LicenseOpt struct {
// Region represents a region of where the license should reside.
// Region represents a region of where the licenses should reside.
Region string `json:"region"`

// Quantity represents how many licenses do we need to create.
// Quantity represents how many licenses do we need to create in a single request.
Quantity int `json:"quantity"`

// Type represents needed type of the license.
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/licenses/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package licenses

import "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/servers"

// License represents a single Resell Floating IP.
// License represents a single Resell License.
type License struct {
// ID is a unique id of the license.
ID int `json:"id"`

// ProjectID represents an associated Resell project.
// ProjectID represents an associated Identity service project.
ProjectID string `json:"project_id"`

// Region represents a region of where the license resides.
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/licenses/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const TestCreateLicenseResponseRaw = `
}
`

// TestCreateLicenseResponse represents the unmarshalled TestCreateFloatingIPResponseRaw response.
// TestCreateLicenseResponse represents the unmarshalled TestCreateLicenseResponseRaw response.
var TestCreateLicenseResponse = []*licenses.License{
{
ID: 1123123,
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/projects/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/quotas"
)

// Project represents a single Resell project.
// Project represents a single Identity service project.
type Project struct {
// ID is a unique id of a project.
ID string `json:"-"`
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/quotas/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"encoding/json"
)

// Quota represents a quota information for a single resource.
// Quota represents a quota information for a single billing resource.
type Quota struct {
// Name is a resource human-readable name.
Name string `json:"-"`

// ResourceQuotasEntities contains information about quotas of a single resource in different locations.
// ResourceQuotasEntities contains information about quotas of a single billing resource in different locations.
ResourceQuotasEntities []ResourceQuotaEntity `json:"-"`
}

Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/roles/requests_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ type RoleOpts struct {

// RoleOpt represents options for a single Resell role.
type RoleOpt struct {
// ProjectID represents needed Resell project.
// ProjectID represents Identity service project.
ProjectID string `json:"project_id"`

// UserID represents needed Resell user.
// UserID represents Identity service user.
UserID string `json:"user_id"`
}
6 changes: 3 additions & 3 deletions selvpcclient/resell/v2/roles/schemas.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package roles

// Role represents a single Resell subnet.
// Role represents a single Resell role.
type Role struct {
// ProjectID represents an associated Resell project.
// ProjectID represents an associated Identity service project.
ProjectID string `json:"project_id"`

// UserID represents an associated Resell user.
// UserID represents an associated Identity service user.
UserID string `json:"user_id"`
}
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/subnets/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ type Subnet struct {
// SubnetID represents id of the associated subnet in the Networking service.
SubnetID string `json:"subnet_id"`

// ProjectID represents an associated Resell project.
// ProjectID represents an associated Identity service project.
ProjectID string `json:"project_id"`
}
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/users/requests_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ type UserOpts struct {
// Password represents a user's password.
Password string `json:"password,omitempty"`

// Enabled shows if user is active or it was disabled.
// Enabled shows if user is active or it needs to be disabled.
Enabled *bool `json:"enabled,omitempty"`
}
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/users/schemas.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package users

// User represents a single user of a Resell project.
// User represents a single user of the Identity service project.
type User struct {
// ID is a unique id of a user.
ID string `json:"id"`

// Name represents the name of a user.
// Name represents the human-readable name of a user.
Name string `json:"name"`

// Enabled shows if user is active or it was disabled.
Expand Down
30 changes: 16 additions & 14 deletions selvpcclient/selvpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,14 @@ const (

// DefaultUserAgent contains basic user agent that will be used in queries.
DefaultUserAgent = "selvpcclient/" + AppVersion

// IPv4 represents IP version 4.
IPv4 IPVersion = "ipv4"

// IPv6 represents IP version 6.
IPv6 IPVersion = "ipv6"

// RFC3339NoZ describes a timestamp format used by some SelVPC responses.
RFC3339NoZ = "2006-01-02T15:04:05"
)

// IPVersion represents a type for the IP versions of the Resell API.
type IPVersion string

// ServiceClient stores details that are needed to work with different Selectel VPC APIs.
type ServiceClient struct {
// HTTPClient represents an initialized HTTP client that will be used to do requests.
HTTPClient *http.Client

// Endpoint represents an enpoint that will be used in all requests.
// Endpoint represents an endpoint that will be used in all requests.
Endpoint string

// TokenID is a client authentication token.
Expand Down Expand Up @@ -90,7 +78,7 @@ func (client *ServiceClient) DoRequest(ctx context.Context, method, url string,
return responseResult, nil
}

// ExtractResult allow to provide an object into which ResponseResult body will be extracted.
// ExtractResult allows to provide an object into which ResponseResult body will be extracted.
func (result *ResponseResult) ExtractResult(to interface{}) error {
body, err := ioutil.ReadAll(result.Body)
defer result.Body.Close()
Expand All @@ -102,6 +90,9 @@ func (result *ResponseResult) ExtractResult(to interface{}) error {
return err
}

// RFC3339NoZ describes a timestamp format used by some SelVPC responses.
const RFC3339NoZ = "2006-01-02T15:04:05"

// JSONRFC3339NoZTimezone is a type for timestamps SelVPC responses with the RFC3339NoZ format.
type JSONRFC3339NoZTimezone time.Time

Expand All @@ -124,3 +115,14 @@ func (jt *JSONRFC3339NoZTimezone) UnmarshalJSON(data []byte) error {
*jt = JSONRFC3339NoZTimezone(t)
return nil
}

const (
// IPv4 represents IP version 4.
IPv4 IPVersion = "ipv4"

// IPv6 represents IP version 6.
IPv6 IPVersion = "ipv6"
)

// IPVersion represents a type for the IP versions of the different Selectel VPC APIs.
type IPVersion string
2 changes: 1 addition & 1 deletion selvpcclient/testutils/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type TestEnv struct {
Client *selvpcclient.ServiceClient
}

// SetupTestEnv prepares the new testing environmenœt.
// SetupTestEnv prepares the new testing environment.
func SetupTestEnv() *TestEnv {
mux := http.NewServeMux()
server := httptest.NewServer(mux)
Expand Down

0 comments on commit d1d4436

Please sign in to comment.