Skip to content

Commit

Permalink
Add skip_init_quotas param (#161)
Browse files Browse the repository at this point in the history
* Add skip_init_quotas param

* Add github actions with tests and linters (#162)

Co-authored-by: Voloshina Tatyana <[email protected]>

---------

Co-authored-by: Voloshina Tatyana <[email protected]>
  • Loading branch information
T-Sh and Voloshina Tatyana authored Apr 10, 2023
1 parent c414863 commit 0bfd18e
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 329 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Golangci-lint
on:
pull_request:

jobs:
golangci-lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.14'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Unit Tests
on:
pull_request:

jobs:
unittests:
name: tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.14'

- name: Run test
run: go test -v ./...
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions selvpcclient/doc.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
Package selvpcclient provides a library to work with the Selectel VPC API.
Authentication
# Authentication
To work with the Selectel VPC API you first need to:
- create a Selectel account: https://my.selectel.ru/registration
- obtain an API token: http://my.selectel.ru/profile/apikeys
- create a Selectel account: https://my.selectel.ru/registration
- obtain an API token: http://my.selectel.ru/profile/apikeys
You can then provide the API token to the selvpc service client.
Service clients
# Service clients
Service client is a special struct that implements a client for different part
of the Selectel VPC API.
Expand Down
10 changes: 5 additions & 5 deletions selvpcclient/resell/v2/capabilities/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ through the Resell v2 API.
Example of getting domain capabilities
domainCapabilities, _, err := capabilities.Get(ctx, resellClient)
if err != nil {
log.Fatal(err)
}
fmt.Println(domainCapabilities)
domainCapabilities, _, err := capabilities.Get(ctx, resellClient)
if err != nil {
log.Fatal(err)
}
fmt.Println(domainCapabilities)
*/
package capabilities
64 changes: 32 additions & 32 deletions selvpcclient/resell/v2/floatingips/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@ the Resell v2 API.
Example of getting a single floating ip referenced by its id
floatingIP, _, err := floatingips.Get(context, resellClient, fipID)
if err != nil {
log.Fatal(err)
}
fmt.Println(floatingIP)
floatingIP, _, err := floatingips.Get(context, resellClient, fipID)
if err != nil {
log.Fatal(err)
}
fmt.Println(floatingIP)
Example of getting all floating ips
allFloatingIPs, _, err := floatingips.List(ctx, resellClient, floatingips.ListOpts{})
if err != nil {
log.Fatal(err)
}
for _, floatingIP := range floatingips {
fmt.Println(floatingIP)
}
allFloatingIPs, _, err := floatingips.List(ctx, resellClient, floatingips.ListOpts{})
if err != nil {
log.Fatal(err)
}
for _, floatingIP := range floatingips {
fmt.Println(floatingIP)
}
Example of creating floating ips in a project
newFloatingIPsOpts := floatingips.FloatingIPOpts{
FloatingIPs: []floatingips.FloatingIPOpt{
{
Region: "ru-2",
Quantity: 2,
},
},
}
projectID := "49338ac045f448e294b25d013f890317"
newFloatingIPs, _, err := floatingips.Create(ctx, resellClient, projectID, newFloatingIPsOpts)
if err != nil {
log.Fatal(err)
}
for _, newFloatingIP := range newFloatingIPs {
fmt.Println(newFloatingIPs)
}
newFloatingIPsOpts := floatingips.FloatingIPOpts{
FloatingIPs: []floatingips.FloatingIPOpt{
{
Region: "ru-2",
Quantity: 2,
},
},
}
projectID := "49338ac045f448e294b25d013f890317"
newFloatingIPs, _, err := floatingips.Create(ctx, resellClient, projectID, newFloatingIPsOpts)
if err != nil {
log.Fatal(err)
}
for _, newFloatingIP := range newFloatingIPs {
fmt.Println(newFloatingIPs)
}
Example of deleting a single floating ip
_, err = floatingips.Delete(ctx, resellClient, "412a04ba-4cb2-4823-abd1-fcd48952b882")
if err != nil {
log.Fatal(err)
}
_, err = floatingips.Delete(ctx, resellClient, "412a04ba-4cb2-4823-abd1-fcd48952b882")
if err != nil {
log.Fatal(err)
}
*/
package floatingips
50 changes: 25 additions & 25 deletions selvpcclient/resell/v2/keypairs/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ the Resell v2 API.
Example of getting keypairs in the current domain
allKeypairs, _, err = keypairs.List(context, resellClient)
if err != nil {
log.Fatal(err)
}
for _, myKeypair := range allKeypairs {
fmt.Println(myKeypair)
}
allKeypairs, _, err = keypairs.List(context, resellClient)
if err != nil {
log.Fatal(err)
}
for _, myKeypair := range allKeypairs {
fmt.Println(myKeypair)
}
Example of creating keypairs in all regions with the same options
newKeypairOptions := keypairs.KeypairOpts{
Name: "my_keypair",
PublicKey: "ssh-rsa public_key_part [email protected]",
UserID: "82a026cae2104e92b999dbe00cdb9435",
}
newKeypairs, _, err := keypairs.Create(ctx, resellClient, newKeypairOptions)
if err != nil {
log.Fatal(err)
}
for _, newKeypair := range newKeypairs {
fmt.Printf("%v\n", newKeypair)
}
newKeypairOptions := keypairs.KeypairOpts{
Name: "my_keypair",
PublicKey: "ssh-rsa public_key_part [email protected]",
UserID: "82a026cae2104e92b999dbe00cdb9435",
}
newKeypairs, _, err := keypairs.Create(ctx, resellClient, newKeypairOptions)
if err != nil {
log.Fatal(err)
}
for _, newKeypair := range newKeypairs {
fmt.Printf("%v\n", newKeypair)
}
Example of deleting a single keypair of a user
keypairName := "my_keypair"
userID := 82a026cae2104e92b999dbe00cdb9435""
_, err = keypairs.Delete(ctx, resellClient, keypairName, userID)
if err != nil {
log.Fatal(err)
}
keypairName := "my_keypair"
userID := 82a026cae2104e92b999dbe00cdb9435""
_, err = keypairs.Delete(ctx, resellClient, keypairName, userID)
if err != nil {
log.Fatal(err)
}
*/
package keypairs
66 changes: 33 additions & 33 deletions selvpcclient/resell/v2/licenses/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ the Resell v2 API.
Example of getting a single license referenced by its id
license, _, err := licenses.Get(context, resellClient, licenseID)
if err != nil {
log.Fatal(err)
}
fmt.Println(license)
license, _, err := licenses.Get(context, resellClient, licenseID)
if err != nil {
log.Fatal(err)
}
fmt.Println(license)
Example of getting all licenses
allLicenses, _, err := licenses.List(ctx, resellClient, licenses.ListOpts{})
if err != nil {
log.Fatal(err)
}
for _, license := range allLicenses {
fmt.Println(license)
}
allLicenses, _, err := licenses.List(ctx, resellClient, licenses.ListOpts{})
if err != nil {
log.Fatal(err)
}
for _, license := range allLicenses {
fmt.Println(license)
}
Example of creating licenses in a project
newLicensesOptions := licenses.LicenseOpts{
Licenses: []licenses.LicenseOpt{
{
Region: "ru-2",
Quantity: 2,
Type: "license_windows_2016_standard",
},
},
}
projectID := "49338ac045f448e294b25d013f890317"
newLicenses, _, err := licenses.Create(ctx, resellClient, projectID, newLicensesOptions)
if err != nil {
log.Fatal(err)
}
for _, newLicense := range newLicenses {
fmt.Printf("%v\n", newLicense)
}
newLicensesOptions := licenses.LicenseOpts{
Licenses: []licenses.LicenseOpt{
{
Region: "ru-2",
Quantity: 2,
Type: "license_windows_2016_standard",
},
},
}
projectID := "49338ac045f448e294b25d013f890317"
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 license
_, err = licenses.Delete(ctx, resellClient, "5232d5f3-4950-454b-bd41-78c5295622cd")
if err != nil {
log.Fatal(err)
}
_, err = licenses.Delete(ctx, resellClient, "5232d5f3-4950-454b-bd41-78c5295622cd")
if err != nil {
log.Fatal(err)
}
*/
package licenses
11 changes: 7 additions & 4 deletions selvpcclient/resell/v2/projects/requests_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ import (
type CreateOpts struct {
// Name sets the name for a new project.
Name string `json:"-"`
// SkipQuotasInit disables quotas initialization for project.
SkipQuotasInit bool `json:"-"`
}

// MarshalJSON implements custom marshalling method for the CreateOpts.
func (opts *CreateOpts) MarshalJSON() ([]byte, error) {
// Return create options with only name and auto_quotas parameters if quotas
// parameter hadn't been provided.
// Return create options with only name and skip_quotas_init parameters.
return json.Marshal(&struct {
Name string `json:"name"`
Name string `json:"name"`
SkipQuotasInit bool `json:"skip_quotas_init"`
}{
Name: opts.Name,
Name: opts.Name,
SkipQuotasInit: opts.SkipQuotasInit,
})
}

Expand Down
3 changes: 2 additions & 1 deletion selvpcclient/resell/v2/projects/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ var TestListProjectsSingleResponse = []*projects.Project{
const TestCreateProjectOptsRaw = `
{
"project": {
"name": "Project2"
"name": "Project2",
"skip_quotas_init": false
}
}
`
Expand Down
Loading

0 comments on commit 0bfd18e

Please sign in to comment.