Skip to content

Commit

Permalink
TECH Remove unnecessary type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Oct 7, 2023
1 parent ee2aee5 commit 2eaa41e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
16 changes: 8 additions & 8 deletions internal/api/json/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewAuth(c *resty.Client) Auth {
}
}

//GetAPIKey gets API keys via REST CLI Gate
// GetAPIKey gets API keys via REST CLI Gate
func (j Auth) GetAPIKey(a api.Auth) (string, error) {
// FIXME: Enable direct call when 18.0.25-18.0.28 are no longer used:
// https://jira.plesk.ru/browse/PPP-49425
Expand All @@ -59,15 +59,15 @@ func (j Auth) GetAPIKey(a api.Auth) (string, error) {
}

if res.IsSuccess() {
var r *createAPIKeyResponse = res.Result().(*createAPIKeyResponse)
var r = res.Result().(*createAPIKeyResponse)
return r.Key, nil
}

if res.StatusCode() == 403 {
return "", authError{server: j.client.HostURL, needReauth: false}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return "", errors.New(locales.L.Get("api.errors.auth.cli.failed", r.Code, r.Message))
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func (j Auth) GetAPIKey(a api.Auth) (string, error) {
}

if res.IsSuccess() {
var r *cliGateResponce = res.Result().(*cliGateResponce)
var r = res.Result().(*cliGateResponce)
if r.Code == 0 {
return r.Stdout, nil
}
Expand All @@ -107,7 +107,7 @@ func (j Auth) GetAPIKey(a api.Auth) (string, error) {
return "", authError{server: j.client.HostURL, needReauth: false}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return "", jsonErrorToError(*r)
}

Expand All @@ -134,7 +134,7 @@ func (j Auth) GetLoginLink(auth api.Auth) (string, error) {
}

if res.IsSuccess() {
var r *cliGateResponce = res.Result().(*cliGateResponce)
var r = res.Result().(*cliGateResponce)
if r.Code == 0 {
return r.Stdout, nil
}
Expand All @@ -146,7 +146,7 @@ func (j Auth) GetLoginLink(auth api.Auth) (string, error) {
return "", authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return "", jsonErrorToError(*r)
}

Expand All @@ -162,7 +162,7 @@ func (j Auth) RemoveAPIKey(auth api.Auth) (string, error) {
}

if res.IsError() {
var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return "", jsonErrorToError(*r)
}

Expand Down
32 changes: 16 additions & 16 deletions internal/api/json/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ func (j jsonDatabases) ListDatabases() ([]api.DatabaseInfo, error) {
}

if res.IsSuccess() {
var r *[]databaseInfo = res.Result().(*[]databaseInfo)
var r = res.Result().(*[]databaseInfo)
return jsonDatabaseInfoToInfo(*r), err
}

if res.StatusCode() == 403 {
return jsonDatabaseInfoToInfo([]databaseInfo{}), authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonDatabaseInfoToInfo([]databaseInfo{}), errors.New(locales.L.Get("api.errors.failed.request", r.Code, r.Message, r.Errors))
}

Expand All @@ -71,15 +71,15 @@ func (j jsonDatabases) ListDomainDatabases(domain string) ([]api.DatabaseInfo, e
}

if res.IsSuccess() {
var r *[]databaseInfo = res.Result().(*[]databaseInfo)
var r = res.Result().(*[]databaseInfo)
return jsonDatabaseInfoToInfo(*r), err
}

if res.StatusCode() == 403 {
return jsonDatabaseInfoToInfo([]databaseInfo{}), authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonDatabaseInfoToInfo([]databaseInfo{}), jsonErrorToError(*r)
}

Expand Down Expand Up @@ -108,7 +108,7 @@ func (j jsonDatabases) CreateDatabase(domain types.Domain, db types.NewDatabase,
}

if res.IsSuccess() {
var r *databaseInfo = res.Result().(*databaseInfo)
var r = res.Result().(*databaseInfo)
return &api.DatabaseInfo{
ID: r.ID,
Name: r.Name,
Expand All @@ -122,7 +122,7 @@ func (j jsonDatabases) CreateDatabase(domain types.Domain, db types.NewDatabase,
return nil, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return nil, jsonErrorToError(*r)
}

Expand All @@ -140,7 +140,7 @@ func (j jsonDatabases) RemoveDatabase(db types.Database) error {
}

if res.IsError() {
var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}

Expand Down Expand Up @@ -209,7 +209,7 @@ func (j jsonDatabases) DeployDatabase(
}

if res.IsSuccess() {
var r *cliGateResponce = res.Result().(*cliGateResponce)
var r = res.Result().(*cliGateResponce)
if r.Code != 0 || len(r.Stderr) != 0 {
return jsonCliGateResponceToError(*r)
}
Expand All @@ -219,7 +219,7 @@ func (j jsonDatabases) DeployDatabase(
return authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}

Expand All @@ -234,15 +234,15 @@ func (j jsonDatabases) ListDatabaseServers() ([]api.DatabaseServerInfo, error) {
}

if res.IsSuccess() {
var r *[]databaseServerInfo = res.Result().(*[]databaseServerInfo)
var r = res.Result().(*[]databaseServerInfo)
return jsonDatabaseServerInfoToInfo(*r), err
}

if res.StatusCode() == 403 {
return []api.DatabaseServerInfo{}, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return []api.DatabaseServerInfo{}, jsonErrorToError(*r)
}

Expand All @@ -268,7 +268,7 @@ func (j jsonDatabases) CreateDatabaseUser(db types.Database, dbuser types.NewDat
}

if res.IsSuccess() {
var r *databaseUserInfo = res.Result().(*databaseUserInfo)
var r = res.Result().(*databaseUserInfo)
return &api.DatabaseUserInfo{
ID: r.ID,
Login: r.Login,
Expand All @@ -280,7 +280,7 @@ func (j jsonDatabases) CreateDatabaseUser(db types.Database, dbuser types.NewDat
return nil, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return nil, jsonErrorToError(*r)
}

Expand All @@ -298,7 +298,7 @@ func (j jsonDatabases) RemoveDatabaseUser(dbu types.DatabaseUser) error {
}

if res.IsError() {
var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}

Expand All @@ -317,14 +317,14 @@ func (j jsonDatabases) ListDatabaseUsers(db types.Database) ([]api.DatabaseUserI
}

if res.IsSuccess() {
var r *[]databaseUserInfo = res.Result().(*[]databaseUserInfo)
var r = res.Result().(*[]databaseUserInfo)
return jsonDatabaseUserInfoToInfo(*r), err
}

if res.StatusCode() == 403 {
return []api.DatabaseUserInfo{}, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return []api.DatabaseUserInfo{}, jsonErrorToError(*r)
}
22 changes: 11 additions & 11 deletions internal/api/json/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (j jsonDomains) getDomainSysUser(d string) (string, error) {
}

if res.IsSuccess() {
var r *cliGateResponce = res.Result().(*cliGateResponce)
var r = res.Result().(*cliGateResponce)
if r.Code != 0 {
return "", jsonCliGateResponceToError(*r)
}
Expand All @@ -88,7 +88,7 @@ func (j jsonDomains) getDomainSysUser(d string) (string, error) {
return "", authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return "", errors.New(locales.L.Get("api.errors.domain.info.failed", r.Code, r.Message))
}

Expand Down Expand Up @@ -128,7 +128,7 @@ func (j jsonDomains) CreateDomain(d string, ipa types.ServerIPAddresses) (*api.D
}

if res.IsSuccess() {
var _ *actionDomainResponse = res.Result().(*actionDomainResponse)
var _ = res.Result().(*actionDomainResponse)
info, err := j.GetDomain(d)
return &info, err
}
Expand All @@ -137,7 +137,7 @@ func (j jsonDomains) CreateDomain(d string, ipa types.ServerIPAddresses) (*api.D
return nil, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return nil, jsonErrorToError(*r)
}

Expand Down Expand Up @@ -166,7 +166,7 @@ func (j jsonDomains) AddDomainFeatures(domain string, featureList []string, isWi
}

if res.IsSuccess() {
var r *cliGateResponce = res.Result().(*cliGateResponce)
var r = res.Result().(*cliGateResponce)
if r.Code == 0 {
return nil
}
Expand All @@ -178,7 +178,7 @@ func (j jsonDomains) AddDomainFeatures(domain string, featureList []string, isWi
return authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}
}
Expand All @@ -198,7 +198,7 @@ func (j jsonDomains) GetDomain(d string) (api.DomainInfo, error) {
}

if res.IsSuccess() {
var r *[]domainInfo = res.Result().(*[]domainInfo)
var r = res.Result().(*[]domainInfo)
if len(*r) == 0 {
return api.DomainInfo{}, errors.New(locales.L.Get("errors.domain.unknown", d))
}
Expand All @@ -223,7 +223,7 @@ func (j jsonDomains) GetDomain(d string) (api.DomainInfo, error) {
return api.DomainInfo{}, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return api.DomainInfo{}, jsonErrorToError(*r)
}

Expand All @@ -246,7 +246,7 @@ func (j jsonDomains) RemoveDomain(d string) error {
}

if res.IsError() {
var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}

Expand All @@ -264,14 +264,14 @@ func (j jsonDomains) ListDomains() ([]api.DomainInfo, error) {
}

if res.IsSuccess() {
var r *[]domainInfo = res.Result().(*[]domainInfo)
var r = res.Result().(*[]domainInfo)
return jsonDomainInfoToInfo(*r), nil
}

if res.StatusCode() == 403 {
return []api.DomainInfo{}, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return []api.DomainInfo{}, jsonErrorToError(*r)
}
14 changes: 7 additions & 7 deletions internal/api/json/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ func (j jsonFTPUsers) ListDomainFtpUsers(domain string, user types.FtpUser) ([]a
}

if res.IsSuccess() {
var r *[]ftpUserInfo = res.Result().(*[]ftpUserInfo)
var r = res.Result().(*[]ftpUserInfo)
return jsonFTPUserInfoToInfo(*r), nil
}

if res.StatusCode() == 403 {
return nil, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return nil, jsonErrorToError(*r)
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func (j jsonFTPUsers) CreateFtpUser(domain string, user types.FtpUser) (*api.FTP
}

if res.IsSuccess() {
var r *ftpUserInfo = res.Result().(*ftpUserInfo)
var r = res.Result().(*ftpUserInfo)
return &api.FTPUserInfo{
Name: r.Home,
Home: r.Name,
Expand All @@ -108,7 +108,7 @@ func (j jsonFTPUsers) CreateFtpUser(domain string, user types.FtpUser) (*api.FTP
return nil, authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return nil, jsonErrorToError(*r)
}

Expand All @@ -135,15 +135,15 @@ func (j jsonFTPUsers) UpdateFtpUser(domain string, user string, userNew types.Ft
}

if res.IsSuccess() {
var _ *statusResponse = res.Result().(*statusResponse)
var _ = res.Result().(*statusResponse)
return nil
}

if res.StatusCode() == 403 {
return authError{server: j.client.HostURL, needReauth: true}
}

var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}

Expand All @@ -161,7 +161,7 @@ func (j jsonFTPUsers) DeleteFtpUser(domain string, user types.FtpUser) error {
}

if res.IsError() {
var r *jsonError = res.Error().(*jsonError)
var r = res.Error().(*jsonError)
return jsonErrorToError(*r)
}

Expand Down
Loading

0 comments on commit 2eaa41e

Please sign in to comment.