Skip to content

Commit 0bfd18e

Browse files
T-ShVoloshina Tatyana
and
Voloshina Tatyana
authored
Add skip_init_quotas param (#161)
* Add skip_init_quotas param * Add github actions with tests and linters (#162) Co-authored-by: Voloshina Tatyana <voloshina@selectel.ru> --------- Co-authored-by: Voloshina Tatyana <voloshina@selectel.ru>
1 parent c414863 commit 0bfd18e

File tree

17 files changed

+359
-329
lines changed

17 files changed

+359
-329
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Golangci-lint
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
golangci-lint:
7+
name: lint
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
13+
- name: Set up Go
14+
uses: actions/setup-go@v3
15+
with:
16+
go-version: '1.14'
17+
18+
- name: golangci-lint
19+
uses: golangci/golangci-lint-action@v3
20+
with:
21+
version: v1.49.0

.github/workflows/tests.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Unit Tests
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
unittests:
7+
name: tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
13+
- name: Set up Go
14+
uses: actions/setup-go@v3
15+
with:
16+
go-version: '1.14'
17+
18+
- name: Run test
19+
run: go test -v ./...

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

selvpcclient/doc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*
22
Package selvpcclient provides a library to work with the Selectel VPC API.
33
4-
Authentication
4+
# Authentication
55
66
To work with the Selectel VPC API you first need to:
77
8-
- create a Selectel account: https://my.selectel.ru/registration
9-
- obtain an API token: http://my.selectel.ru/profile/apikeys
8+
- create a Selectel account: https://my.selectel.ru/registration
9+
- obtain an API token: http://my.selectel.ru/profile/apikeys
1010
1111
You can then provide the API token to the selvpc service client.
1212
13-
Service clients
13+
# Service clients
1414
1515
Service client is a special struct that implements a client for different part
1616
of the Selectel VPC API.

selvpcclient/resell/v2/capabilities/doc.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ through the Resell v2 API.
44
55
Example of getting domain capabilities
66
7-
domainCapabilities, _, err := capabilities.Get(ctx, resellClient)
8-
if err != nil {
9-
log.Fatal(err)
10-
}
11-
fmt.Println(domainCapabilities)
7+
domainCapabilities, _, err := capabilities.Get(ctx, resellClient)
8+
if err != nil {
9+
log.Fatal(err)
10+
}
11+
fmt.Println(domainCapabilities)
1212
*/
1313
package capabilities

selvpcclient/resell/v2/floatingips/doc.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,46 @@ the Resell v2 API.
44
55
Example of getting a single floating ip referenced by its id
66
7-
floatingIP, _, err := floatingips.Get(context, resellClient, fipID)
8-
if err != nil {
9-
log.Fatal(err)
10-
}
11-
fmt.Println(floatingIP)
7+
floatingIP, _, err := floatingips.Get(context, resellClient, fipID)
8+
if err != nil {
9+
log.Fatal(err)
10+
}
11+
fmt.Println(floatingIP)
1212
1313
Example of getting all floating ips
1414
15-
allFloatingIPs, _, err := floatingips.List(ctx, resellClient, floatingips.ListOpts{})
16-
if err != nil {
17-
log.Fatal(err)
18-
}
19-
for _, floatingIP := range floatingips {
20-
fmt.Println(floatingIP)
21-
}
15+
allFloatingIPs, _, err := floatingips.List(ctx, resellClient, floatingips.ListOpts{})
16+
if err != nil {
17+
log.Fatal(err)
18+
}
19+
for _, floatingIP := range floatingips {
20+
fmt.Println(floatingIP)
21+
}
2222
2323
Example of creating floating ips in a project
2424
25-
newFloatingIPsOpts := floatingips.FloatingIPOpts{
26-
FloatingIPs: []floatingips.FloatingIPOpt{
27-
{
28-
Region: "ru-2",
29-
Quantity: 2,
30-
},
31-
},
32-
}
33-
projectID := "49338ac045f448e294b25d013f890317"
34-
newFloatingIPs, _, err := floatingips.Create(ctx, resellClient, projectID, newFloatingIPsOpts)
35-
if err != nil {
36-
log.Fatal(err)
37-
}
38-
for _, newFloatingIP := range newFloatingIPs {
39-
fmt.Println(newFloatingIPs)
40-
}
25+
newFloatingIPsOpts := floatingips.FloatingIPOpts{
26+
FloatingIPs: []floatingips.FloatingIPOpt{
27+
{
28+
Region: "ru-2",
29+
Quantity: 2,
30+
},
31+
},
32+
}
33+
projectID := "49338ac045f448e294b25d013f890317"
34+
newFloatingIPs, _, err := floatingips.Create(ctx, resellClient, projectID, newFloatingIPsOpts)
35+
if err != nil {
36+
log.Fatal(err)
37+
}
38+
for _, newFloatingIP := range newFloatingIPs {
39+
fmt.Println(newFloatingIPs)
40+
}
4141
4242
Example of deleting a single floating ip
4343
44-
_, err = floatingips.Delete(ctx, resellClient, "412a04ba-4cb2-4823-abd1-fcd48952b882")
45-
if err != nil {
46-
log.Fatal(err)
47-
}
44+
_, err = floatingips.Delete(ctx, resellClient, "412a04ba-4cb2-4823-abd1-fcd48952b882")
45+
if err != nil {
46+
log.Fatal(err)
47+
}
4848
*/
4949
package floatingips

selvpcclient/resell/v2/keypairs/doc.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ the Resell v2 API.
44
55
Example of getting keypairs in the current domain
66
7-
allKeypairs, _, err = keypairs.List(context, resellClient)
8-
if err != nil {
9-
log.Fatal(err)
10-
}
11-
for _, myKeypair := range allKeypairs {
12-
fmt.Println(myKeypair)
13-
}
7+
allKeypairs, _, err = keypairs.List(context, resellClient)
8+
if err != nil {
9+
log.Fatal(err)
10+
}
11+
for _, myKeypair := range allKeypairs {
12+
fmt.Println(myKeypair)
13+
}
1414
1515
Example of creating keypairs in all regions with the same options
1616
17-
newKeypairOptions := keypairs.KeypairOpts{
18-
Name: "my_keypair",
19-
PublicKey: "ssh-rsa public_key_part user0@example.org",
20-
UserID: "82a026cae2104e92b999dbe00cdb9435",
21-
}
22-
newKeypairs, _, err := keypairs.Create(ctx, resellClient, newKeypairOptions)
23-
if err != nil {
24-
log.Fatal(err)
25-
}
26-
for _, newKeypair := range newKeypairs {
27-
fmt.Printf("%v\n", newKeypair)
28-
}
17+
newKeypairOptions := keypairs.KeypairOpts{
18+
Name: "my_keypair",
19+
PublicKey: "ssh-rsa public_key_part user0@example.org",
20+
UserID: "82a026cae2104e92b999dbe00cdb9435",
21+
}
22+
newKeypairs, _, err := keypairs.Create(ctx, resellClient, newKeypairOptions)
23+
if err != nil {
24+
log.Fatal(err)
25+
}
26+
for _, newKeypair := range newKeypairs {
27+
fmt.Printf("%v\n", newKeypair)
28+
}
2929
3030
Example of deleting a single keypair of a user
3131
32-
keypairName := "my_keypair"
33-
userID := 82a026cae2104e92b999dbe00cdb9435""
34-
_, err = keypairs.Delete(ctx, resellClient, keypairName, userID)
35-
if err != nil {
36-
log.Fatal(err)
37-
}
32+
keypairName := "my_keypair"
33+
userID := 82a026cae2104e92b999dbe00cdb9435""
34+
_, err = keypairs.Delete(ctx, resellClient, keypairName, userID)
35+
if err != nil {
36+
log.Fatal(err)
37+
}
3838
*/
3939
package keypairs

selvpcclient/resell/v2/licenses/doc.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,47 @@ the Resell v2 API.
44
55
Example of getting a single license referenced by its id
66
7-
license, _, err := licenses.Get(context, resellClient, licenseID)
8-
if err != nil {
9-
log.Fatal(err)
10-
}
11-
fmt.Println(license)
7+
license, _, err := licenses.Get(context, resellClient, licenseID)
8+
if err != nil {
9+
log.Fatal(err)
10+
}
11+
fmt.Println(license)
1212
1313
Example of getting all licenses
1414
15-
allLicenses, _, err := licenses.List(ctx, resellClient, licenses.ListOpts{})
16-
if err != nil {
17-
log.Fatal(err)
18-
}
19-
for _, license := range allLicenses {
20-
fmt.Println(license)
21-
}
15+
allLicenses, _, err := licenses.List(ctx, resellClient, licenses.ListOpts{})
16+
if err != nil {
17+
log.Fatal(err)
18+
}
19+
for _, license := range allLicenses {
20+
fmt.Println(license)
21+
}
2222
2323
Example of creating licenses in a project
2424
25-
newLicensesOptions := licenses.LicenseOpts{
26-
Licenses: []licenses.LicenseOpt{
27-
{
28-
Region: "ru-2",
29-
Quantity: 2,
30-
Type: "license_windows_2016_standard",
31-
},
32-
},
33-
}
34-
projectID := "49338ac045f448e294b25d013f890317"
35-
newLicenses, _, err := licenses.Create(ctx, resellClient, projectID, newLicensesOptions)
36-
if err != nil {
37-
log.Fatal(err)
38-
}
39-
for _, newLicense := range newLicenses {
40-
fmt.Printf("%v\n", newLicense)
41-
}
25+
newLicensesOptions := licenses.LicenseOpts{
26+
Licenses: []licenses.LicenseOpt{
27+
{
28+
Region: "ru-2",
29+
Quantity: 2,
30+
Type: "license_windows_2016_standard",
31+
},
32+
},
33+
}
34+
projectID := "49338ac045f448e294b25d013f890317"
35+
newLicenses, _, err := licenses.Create(ctx, resellClient, projectID, newLicensesOptions)
36+
if err != nil {
37+
log.Fatal(err)
38+
}
39+
for _, newLicense := range newLicenses {
40+
fmt.Printf("%v\n", newLicense)
41+
}
4242
4343
Example of deleting a single license
4444
45-
_, err = licenses.Delete(ctx, resellClient, "5232d5f3-4950-454b-bd41-78c5295622cd")
46-
if err != nil {
47-
log.Fatal(err)
48-
}
45+
_, err = licenses.Delete(ctx, resellClient, "5232d5f3-4950-454b-bd41-78c5295622cd")
46+
if err != nil {
47+
log.Fatal(err)
48+
}
4949
*/
5050
package licenses

selvpcclient/resell/v2/projects/requests_opts.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ import (
88
type CreateOpts struct {
99
// Name sets the name for a new project.
1010
Name string `json:"-"`
11+
// SkipQuotasInit disables quotas initialization for project.
12+
SkipQuotasInit bool `json:"-"`
1113
}
1214

1315
// MarshalJSON implements custom marshalling method for the CreateOpts.
1416
func (opts *CreateOpts) MarshalJSON() ([]byte, error) {
15-
// Return create options with only name and auto_quotas parameters if quotas
16-
// parameter hadn't been provided.
17+
// Return create options with only name and skip_quotas_init parameters.
1718
return json.Marshal(&struct {
18-
Name string `json:"name"`
19+
Name string `json:"name"`
20+
SkipQuotasInit bool `json:"skip_quotas_init"`
1921
}{
20-
Name: opts.Name,
22+
Name: opts.Name,
23+
SkipQuotasInit: opts.SkipQuotasInit,
2124
})
2225
}
2326

selvpcclient/resell/v2/projects/testing/fixtures.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ var TestListProjectsSingleResponse = []*projects.Project{
103103
const TestCreateProjectOptsRaw = `
104104
{
105105
"project": {
106-
"name": "Project2"
106+
"name": "Project2",
107+
"skip_quotas_init": false
107108
}
108109
}
109110
`

0 commit comments

Comments
 (0)