Skip to content

Commit c4a0db9

Browse files
authored
Release 0.1.1 (#5)
* Add user and backup methods * Added test to dns and user methods, some other fixes Added test to dns and user methods Added test mode Added function to clone map Other Changes * End testing and formated code * Add documentation. Add codecov * Add codecov token
1 parent e1f1abb commit c4a0db9

43 files changed

Lines changed: 2547 additions & 93 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ on:
1010
- main
1111
- dev/*/main
1212
pull_request:
13-
13+
branches:
14+
- main
1415
jobs:
1516
lint:
1617
runs-on: ubuntu-latest
@@ -29,10 +30,6 @@ jobs:
2930
run: go install honnef.co/go/tools/cmd/staticcheck@latest
3031
- name: Run staticcheck
3132
run: staticcheck ./...
32-
- name: Install golint
33-
run: go install golang.org/x/lint/golint@latest
34-
- name: Run golint
35-
run: golint ./...
3633
golangci-lint:
3734
runs-on: ubuntu-latest
3835
steps:
@@ -75,7 +72,11 @@ jobs:
7572
- name: Verify dependencies
7673
run: go mod verify
7774
- name: Run tests
78-
run: go test -race -vet=off ./...
75+
run: go test -race -vet=off -covermode=atomic -coverprofile=coverage.out ./...
76+
- name: Upload coverage to Codecov
77+
uses: codecov/codecov-action@v4
78+
env:
79+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7980
build:
8081
runs-on: ubuntu-latest
8182
needs: [test]

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ linters-settings:
8585
disabled: true
8686
- name: errorf
8787
disabled: true
88+
- name: var-naming
89+
disabled: true
8890
gci:
8991
local-prefixes: github.com/ThCompiler/go.beget.api
9092
dupl:

CHANGELOG-RU.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,37 @@
7474

7575
#### Api
7676

77-
* Добавлена документация Golang.
77+
* Добавлена документация Golang.
78+
79+
## 0.1.1
80+
81+
## Изменено
82+
83+
### Библиотека
84+
85+
#### Api
86+
87+
* Добавлено получение `url.Values` в качестве параметра метода `CallMethod` структуры `BasicMethod` в пакете **api**.
88+
И, соответственно, появилась возможность добавлять в информацию о методе API параметры запроса.
89+
90+
## Добавлено
91+
92+
### Библиотека
93+
94+
#### Ядро
95+
96+
* Добавлен метод `PrepareRequestWithClient` в пакете **core**, позволяющий указывать пользовательский
97+
`http.Client` для запросов к API.
98+
* Добавлено тестовое состояние для работы API.
99+
100+
#### Api
101+
102+
* Добавлен пакет тест в пакет *api* с тестами API методов.
103+
* Добавлены методы [управления аккаунтами](https://beget.com/ru/kb/api/funkczii-upravleniya-akkauntom) в
104+
пакет **api/user**.
105+
* Добавлены методы [управления бэкапами](https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami) в
106+
пакет **api/backup**.
107+
108+
### Pkg
109+
110+
* Добавлена функция для клонирования `map`.

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,36 @@
7575

7676
#### Api
7777

78-
* Added golang documentation.
78+
* Added golang documentation.
79+
80+
## 0.1.1
81+
82+
## Changed
83+
84+
### Library
85+
86+
#### Api
87+
88+
* Added getting the `url.Values` as a parameter of the `callMethod` method of the `BasicMethod` structure
89+
in the **api** package. And, accordingly, it is now possible to add query parameters to the API method information.
90+
91+
## Added
92+
93+
### Library
94+
95+
#### Core
96+
97+
* Added method `PrepareRequestWithClient` in the **core** package to specify user\`s `http.Client` for requests to API.
98+
* Added test mod for working api system.
99+
100+
#### Api
101+
102+
* Added test package to **api** package with tests of API methods.
103+
* Added methods of [account management](https://beget.com/ru/kb/api/funkczii-upravleniya-akkauntom) in the
104+
**api/user** package.
105+
* Added methods of [backup management](https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami) in the
106+
**api/backup** package.
107+
108+
### Pkg
109+
110+
* Added a function for cloning the `map`.

README-RU.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Go Report Card](https://goreportcard.com/badge/github.com/ThCompiler/go.beget.api)](https://goreportcard.com/report/github.com/ThCompiler/go.beget.api)
22
[![Go Reference](https://pkg.go.dev/badge/github.com/ThCompiler/go.beget.api.svg)](https://pkg.go.dev/github.com/ThCompiler/go.beget.api)
3+
[![codecov](https://codecov.io/gh/ThCompiler/go.beget.api/graph/badge.svg?token=1B0YBTYJ4T)](https://codecov.io/gh/ThCompiler/go.beget.api)
34

45
[![en](https://img.shields.io/badge/lang-en-red.svg)](./README.md)
56

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Go Report Card](https://goreportcard.com/badge/github.com/ThCompiler/go.beget.api)](https://goreportcard.com/report/github.com/ThCompiler/go.beget.api)
22
[![Go Reference](https://pkg.go.dev/badge/github.com/ThCompiler/go.beget.api.svg)](https://pkg.go.dev/github.com/ThCompiler/go.beget.api)
3-
3+
[![codecov](https://codecov.io/gh/ThCompiler/go.beget.api/graph/badge.svg?token=1B0YBTYJ4T)](https://codecov.io/gh/ThCompiler/go.beget.api)
44

55
[![en](https://img.shields.io/badge/lang-ru-green.svg)](./README-RU.md)
66

TODO.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
### [Управление аккаунтом](https://beget.com/ru/kb/api/funkczii-upravleniya-akkauntom)
44

5-
* [ ] getAccountInfo
6-
* [ ] toggleSsh
5+
* [x] getAccountInfo
6+
* [x] toggleSsh
77

88
### [Управление бэкапами](https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami)
99

10-
* [ ] getFileBackupList
11-
* [ ] getMysqlBackupList
12-
* [ ] getFileList
13-
* [ ] getMysqlList
14-
* [ ] restoreFile
15-
* [ ] restoreMysql
16-
* [ ] downloadFile
17-
* [ ] downloadMysql
18-
* [ ] getLog
10+
* [x] getFileBackupList
11+
* [x] getMysqlBackupList
12+
* [x] getFileList
13+
* [x] getMysqlList
14+
* [x] restoreFile
15+
* [x] restoreMysql
16+
* [x] downloadFile
17+
* [x] downloadMysql
18+
* [x] getLog
1919

2020
### [Управление Cron](https://beget.com/ru/kb/api/funkczii-upravleniya-cron)
2121

api/backup/constants.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Package backup implements the functionality of [Backup methods].
2+
// Package implements [getFileBackupList], [getMysqlBackupList],
3+
// [getFileList], [getMysqlList], [restoreFile], [restoreMysql], [downloadFile], [downloadMysql], [getLog] methods.
4+
// To create the appropriate methods, you need to call either [CallGetFileBackupList], [CallGetMysqlBackupList],
5+
// [CallGetFileList], [CallGetMysqlList], [CallRestoreFile], [CallRestoreMysql], [CallDownloadFile],
6+
// [CallDownloadMysql] or [CallGetLog].
7+
//
8+
// [Backup methods]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami
9+
// [getFileBackupList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getfilebackuplist
10+
// [getMysqlBackupList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getmysqlbackuplist
11+
// [getFileList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getfilelist
12+
// [getMysqlList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getmysqllist
13+
// [restoreFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#restorefile
14+
// [restoreMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#restoremysql
15+
// [downloadFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadfile
16+
// [downloadMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadmysql
17+
// [getLog]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getlog
18+
package backup
19+
20+
// Constants used to implement the [getFileBackupList], [getMysqlBackupList],
21+
// [getFileList], [getMysqlList], [restoreFile], [restoreMysql], [downloadFile], [downloadMysql], [getLog] methods.
22+
//
23+
// [getFileBackupList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getfilebackuplist
24+
// [getMysqlBackupList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getmysqlbackuplist
25+
// [getFileList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getfilelist
26+
// [getMysqlList]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getmysqllist
27+
// [restoreFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#restorefile
28+
// [restoreMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#restoremysql
29+
// [downloadFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadfile
30+
// [downloadMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadmysql
31+
// [getLog]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#getlog
32+
const (
33+
GetFileBackupListMethodName = "GetFileBackupList"
34+
GetFileBackupListMethodPath = "backup/getFileBackupList"
35+
36+
GetMysqlBackupListMethodName = "GetMysqlBackupList"
37+
GetMysqlBackupListMethodPath = "backup/getMysqlBackupList"
38+
39+
GetFileListMethodName = "GetFileList"
40+
GetFileListMethodPath = "backup/getFileList"
41+
42+
GetMysqlListMethodName = "GetMysqlList"
43+
GetMysqlListMethodPath = "backup/getMysqlList"
44+
45+
RestoreFileMethodName = "RestoreFile"
46+
RestoreFileMethodPath = "backup/restoreFile"
47+
48+
RestoreMysqlMethodName = "RestoreMysql"
49+
RestoreMysqlMethodPath = "backup/restoreMysql"
50+
51+
DownloadFileMethodName = "DownloadFile"
52+
DownloadFileMethodPath = "backup/downloadFile"
53+
54+
DownloadMysqlMethodName = "DownloadMysql"
55+
DownloadMysqlMethodPath = "backup/downloadMysql"
56+
57+
GetLogMethodName = "GetLog"
58+
GetLogMethodPath = "backup/getLog"
59+
)

api/backup/download_file.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package backup
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/ThCompiler/go.beget.api/api"
7+
"github.com/ThCompiler/go.beget.api/api/result"
8+
"github.com/ThCompiler/go.beget.api/core"
9+
)
10+
11+
type downloadFile struct {
12+
api.BasicMethod
13+
}
14+
15+
// CallDownloadFile is a creation function that returns a [core.APIMethod] corresponding to the method [downloadFile].
16+
// The function expects the backup ID from which files need to be downloaded
17+
// and a list of paths from which files are downloaded.
18+
// If the backup ID is a nil, the databases will be searched in the current copy.
19+
//
20+
// [downloadFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadfile
21+
func CallDownloadFile(backupID *result.ID, paths []string) core.APIMethod[result.BoolResult] {
22+
return &downloadFile{
23+
BasicMethod: *api.CallMethod(
24+
DownloadFileMethodPath,
25+
&downloadFileRequest{BackupID: backupID, Paths: paths},
26+
nil,
27+
),
28+
}
29+
}
30+
31+
// GetHTTPMethod returns name of http method for method [downloadFile].
32+
//
33+
// [downloadFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadfile
34+
func (*downloadFile) GetHTTPMethod() string {
35+
return http.MethodPost
36+
}
37+
38+
// GetName returns name of method [downloadFile].
39+
//
40+
// [downloadFile]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadfile
41+
func (*downloadFile) GetName() core.MethodName {
42+
return DownloadFileMethodName
43+
}
44+
45+
type downloadFileRequest struct {
46+
BackupID *result.ID `json:"backup_id,omitempty"`
47+
Paths []string `json:"paths"`
48+
}

api/backup/download_mysql.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package backup
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/ThCompiler/go.beget.api/api"
7+
"github.com/ThCompiler/go.beget.api/api/result"
8+
"github.com/ThCompiler/go.beget.api/core"
9+
)
10+
11+
type downloadMysql struct {
12+
api.BasicMethod
13+
}
14+
15+
// CallDownloadMysql is a creation function that returns a [core.APIMethod] corresponding to the method [downloadMysql].
16+
// The function expects the backup ID from which data needs to be downloaded,
17+
// and a list of databases whose data is being downloaded.
18+
// If the backup ID is a nil, the databases will be searched in the current copy.
19+
//
20+
// [downloadMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadmysql
21+
func CallDownloadMysql(backupID *result.ID, bases []result.DatabaseName) core.APIMethod[result.BoolResult] {
22+
return &downloadMysql{
23+
BasicMethod: *api.CallMethod(
24+
DownloadMysqlMethodPath,
25+
&downloadMysqlRequest{BackupID: backupID, Bases: bases},
26+
nil,
27+
),
28+
}
29+
}
30+
31+
// GetHTTPMethod returns name of http method for method [downloadMysql].
32+
//
33+
// [downloadMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadmysql
34+
func (*downloadMysql) GetHTTPMethod() string {
35+
return http.MethodPost
36+
}
37+
38+
// GetName returns name of method [downloadMysql].
39+
//
40+
// [downloadMysql]: https://beget.com/ru/kb/api/funkczii-upravleniya-bekapami#downloadmysql
41+
func (*downloadMysql) GetName() core.MethodName {
42+
return DownloadMysqlMethodName
43+
}
44+
45+
type downloadMysqlRequest struct {
46+
BackupID *result.ID `json:"backup_id,omitempty"`
47+
Bases []result.DatabaseName `json:"bases"`
48+
}

0 commit comments

Comments
 (0)