v9.0.0
This commit is contained in:
41
pkg/cloudbroker/apiaccess/api_find.go
Normal file
41
pkg/cloudbroker/apiaccess/api_find.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// APIFindRequest struct for finding apiaccess groups.
|
||||
type APIFindRequest struct {
|
||||
// API function to find
|
||||
// Example: cloudbroker/k8s/create
|
||||
// Required: true
|
||||
APIName string `url:"apiName" json:"apiName" validate:"required"`
|
||||
}
|
||||
|
||||
// APIFind outputs a list of apiaccess groups that mention the specified API function.
|
||||
func (a APIAccess) APIFind(ctx context.Context, req APIFindRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/apiFind"
|
||||
|
||||
list := make([]uint64, 0)
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
15
pkg/cloudbroker/apiaccess/apiaccess.go
Normal file
15
pkg/cloudbroker/apiaccess/apiaccess.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package apiaccess
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/interfaces"
|
||||
|
||||
// Structure for creating request to APIAccess
|
||||
type APIAccess struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for APIAccess endpoints
|
||||
func New(client interfaces.Caller) *APIAccess {
|
||||
return &APIAccess{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
69
pkg/cloudbroker/apiaccess/apis_exclude.go
Normal file
69
pkg/cloudbroker/apiaccess/apis_exclude.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
type APIString string
|
||||
|
||||
// APIsExcludeRequest struct for removing api from access group.
|
||||
type APIsExcludeRequest struct {
|
||||
// APIAccess group ID
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// APIs to remove from APIAccess group
|
||||
// Required: true
|
||||
APIs APIString `url:"-" json:"apis" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperAPIsExcludeRequest struct {
|
||||
APIsExcludeRequest
|
||||
|
||||
APIString string `url:"apis"`
|
||||
}
|
||||
|
||||
// APIsExclude removes the listed API functions from the specified apiaccess group.
|
||||
func (a APIAccess) APIsExclude(ctx context.Context, req APIsExcludeRequest) (*APIsEndpoints, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/apisExclude"
|
||||
|
||||
info := APIsEndpoints{}
|
||||
|
||||
apiJSON, err := json.Marshal(&req.APIs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiJSONPretty, err := json.MarshalIndent(&req.APIs, "", " ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(string(apiJSONPretty))
|
||||
|
||||
reqWrapped := wrapperAPIsExcludeRequest{
|
||||
APIsExcludeRequest: req,
|
||||
APIString: string(apiJSON),
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
60
pkg/cloudbroker/apiaccess/apis_include.go
Normal file
60
pkg/cloudbroker/apiaccess/apis_include.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// APIsIncludeRequest struct for adding api to access group.
|
||||
type APIsIncludeRequest struct {
|
||||
// APIAccess group ID.
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// APIs to add to APIAccess group.
|
||||
// Required: true
|
||||
APIs APIString `url:"-" json:"apis" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperAPIsIncludeRequest struct {
|
||||
APIsIncludeRequest
|
||||
|
||||
APIString string `url:"apis"`
|
||||
}
|
||||
|
||||
// APIsInclude adds the listed API functions to the specified apiaccess group.
|
||||
func (a APIAccess) APIsInclude(ctx context.Context, req APIsIncludeRequest) (*APIsEndpoints, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/apisInclude"
|
||||
|
||||
info := APIsEndpoints{}
|
||||
|
||||
apiJSON, err := json.Marshal(&req.APIs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reqWrapped := wrapperAPIsIncludeRequest{
|
||||
APIsIncludeRequest: req,
|
||||
APIString: string(apiJSON),
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
42
pkg/cloudbroker/apiaccess/copy.go
Normal file
42
pkg/cloudbroker/apiaccess/copy.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// CopyRequest Request for copying apiaccess group.
|
||||
type CopyRequest struct {
|
||||
// ID of the API access group to make copy from
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// Name of the target API access group, which will be created on successful copy
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
// Copy creates a copy of the specified apiaccess group with a new name (and a new unique ID).
|
||||
func (a APIAccess) Copy(ctx context.Context, req CopyRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/copy"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/apiaccess/create.go
Normal file
42
pkg/cloudbroker/apiaccess/create.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for creating apiaccess group.
|
||||
type CreateRequest struct {
|
||||
// Name of this apiaccess group.
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Description of this apiaccess group.
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates apiaccess group.
|
||||
func (a APIAccess) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/create"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/apiaccess/delete.go
Normal file
42
pkg/cloudbroker/apiaccess/delete.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct for deleting apiaccess group.
|
||||
type DeleteRequest struct {
|
||||
// APIAccess group ID.
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// Set True to delete apiaccess group with attached users.
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// Delete deletes apiaccess group
|
||||
func (a APIAccess) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/delete"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/apiaccess/desc_update.go
Normal file
42
pkg/cloudbroker/apiaccess/desc_update.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// DescUpdateRequest struct for updating apiaccess group description.
|
||||
type DescUpdateRequest struct {
|
||||
// APIAccess group ID.
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// New description to set for the apiaccess group.
|
||||
// Required: true
|
||||
Description string `url:"desc" json:"desc" validate:"required"`
|
||||
}
|
||||
|
||||
// DescUpdate sets a new text description of the apiaccess group.
|
||||
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/descUpdate"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/apiaccess/get.go
Normal file
46
pkg/cloudbroker/apiaccess/get.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get apiaccess group.
|
||||
type GetRequest struct {
|
||||
// APIAccess group ID.
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets apiaccess group as an ItemAPIAccess struct
|
||||
func (a APIAccess) Get(ctx context.Context, req GetRequest) (*ItemAPIAccess, error) {
|
||||
res, err := a.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ItemAPIAccess{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets apiaccess group as an array of bytes
|
||||
func (a APIAccess) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
26
pkg/cloudbroker/apiaccess/get_full.go
Normal file
26
pkg/cloudbroker/apiaccess/get_full.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetFull gets full current endpoints dictionary
|
||||
func (a APIAccess) GetFull(ctx context.Context) (*APIsEndpoints, error) {
|
||||
url := "/cloudbroker/apiaccess/getFull"
|
||||
|
||||
info := APIsEndpoints{}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
26
pkg/cloudbroker/apiaccess/get_pre_groups.go
Normal file
26
pkg/cloudbroker/apiaccess/get_pre_groups.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetPreGroups gets list of pre default groups from spec
|
||||
func (a APIAccess) GetPreGroups(ctx context.Context) (map[string]APIsEndpoints, error) {
|
||||
url := "/cloudbroker/apiaccess/getPreGroups"
|
||||
|
||||
info := make(map[string]APIsEndpoints)
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
10
pkg/cloudbroker/apiaccess/ids.go
Normal file
10
pkg/cloudbroker/apiaccess/ids.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package apiaccess
|
||||
|
||||
// IDs gets array of APIAccessId from ListAPIAccess struct
|
||||
func (laa ListAPIAccess) IDs() []uint64 {
|
||||
res := make([]uint64, 0, len(laa.Data))
|
||||
for _, apiaccess := range laa.Data {
|
||||
res = append(res, apiaccess.ID)
|
||||
}
|
||||
return res
|
||||
}
|
||||
79
pkg/cloudbroker/apiaccess/list.go
Normal file
79
pkg/cloudbroker/apiaccess/list.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of all non deleted apiaccess instances.
|
||||
type ListRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by name apiaccess
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by status apiaccess
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by created actor
|
||||
// Required: false
|
||||
CreatedBy string `url:"createdBy,omitempty" json:"createdBy,omitempty"`
|
||||
|
||||
// Find by created after time (unix timestamp)
|
||||
// Required: false
|
||||
CreatedAfter uint64 `url:"createdAfter,omitempty" json:"createdAfter,omitempty"`
|
||||
|
||||
// Find by created before time (unix timestamp)
|
||||
// Required: false
|
||||
CreatedBefore uint64 `url:"createdBefore,omitempty" json:"createdBefore,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size, maximum - 100
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of all non deleted apiaccess instances as a ListAPIAccess struct
|
||||
func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, error) {
|
||||
|
||||
res, err := a.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ListAPIAccess{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of all non deleted apiaccess instances as an array of bytes
|
||||
func (a APIAccess) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
48
pkg/cloudbroker/apiaccess/list_deleted.go
Normal file
48
pkg/cloudbroker/apiaccess/list_deleted.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct for getting list of all deleted apiaccess instances.
|
||||
type ListDeletedRequest struct {
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page number.
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size.
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ListDeleted gets list of all deleted apiaccess instances.
|
||||
func (a APIAccess) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAPIAccess, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/listDeleted"
|
||||
|
||||
info := ListAPIAccess{}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
180
pkg/cloudbroker/apiaccess/models.go
Normal file
180
pkg/cloudbroker/apiaccess/models.go
Normal file
@@ -0,0 +1,180 @@
|
||||
package apiaccess
|
||||
|
||||
type ItemAPIAccess struct {
|
||||
// APIs
|
||||
APIs APIsEndpoints `json:"apis"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Is default
|
||||
Default bool `json:"default"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"decs"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Is protected
|
||||
Protected bool `json:"protected"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
//Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type ListAPIAccess struct {
|
||||
Data []ItemAPIAccess `json:"data"`
|
||||
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type APIsEndpoints struct {
|
||||
// CloudAPI endpoints
|
||||
CloudAPI CloudAPIEndpoints `json:"cloudapi,omitempty"`
|
||||
|
||||
// CloudBroker endpoints
|
||||
CloudBroker CloudBrokerEndpoints `json:"cloudbroker,omitempty"`
|
||||
|
||||
// LibCloud endpoints
|
||||
LibCloud LibCloudEndpoints `json:"libcloud,omitempty"`
|
||||
|
||||
// System endpoints
|
||||
System SystemEndpoints `json:"system,omitempty"`
|
||||
}
|
||||
|
||||
type CloudAPIEndpoints struct {
|
||||
Account []string `json:"account,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
ComputeCI []string `json:"computeci,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FLIPGroup []string `json:"flipgroup,omitempty"`
|
||||
GPU []string `json:"gpu,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Loactions []string `json:"locations,omitempty"`
|
||||
Machine []string `json:"machine,omitempty"`
|
||||
Openshift []string `json:"openshift,omitempty"`
|
||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
PortForwarding []string `json:"portforwarding,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
Sizes []string `json:"sizes,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type CloudBrokerEndpoints struct {
|
||||
Account []string `json:"account,omitempty"`
|
||||
APIAccess []string `json:"apiaccess,omitempty"`
|
||||
Audit interface{} `json:"audit,omitempty"`
|
||||
AuditBeat []string `json:"auditbeat,omitempty"`
|
||||
AuditCollector []string `json:"auditcollector,omitempty"`
|
||||
BackupCreator []string `json:"backupcreator,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
ComputeCI []string `json:"computeci,omitempty"`
|
||||
Desnode []string `json:"desnode,omitempty"`
|
||||
Diagnostics []string `json:"diagnostics,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
Eco []string `json:"eco,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FlIPgroup []string `json:"flipgroup,omitempty"`
|
||||
Grid []string `json:"grid,omitempty"`
|
||||
Group []string `json:"group,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
IaaS []string `json:"iaas,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
Job interface{} `json:"job,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Machine []string `json:"machine,omitempty"`
|
||||
Metering []string `json:"metering,omitempty"`
|
||||
Milestones []string `json:"milestones,omitempty"`
|
||||
Node []string `json:"node,omitempty"`
|
||||
Openshift []string `json:"openshift,omitempty"`
|
||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||
Ovsnode []string `json:"ovsnode,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
PGPU []string `json:"pgpu,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
QOS []string `json:"qos,omitempty"`
|
||||
Resmon interface{} `json:"resmon,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
Sep []string `json:"sep,omitempty"`
|
||||
Stack []string `json:"stack,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
TLock []string `json:"tlock,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
VNFDev []string `json:"vnfdev,omitempty"`
|
||||
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type LibCloudEndpoints struct {
|
||||
Libvirt []string `json:"libvirt,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type SystemEndpoints struct {
|
||||
AgentController []string `json:"agentcontroller,omitempty"`
|
||||
Alerts []string `json:"alerts,omitempty"`
|
||||
Audits []string `json:"audits,omitempty"`
|
||||
ContentManager []string `json:"contentmanager,omitempty"`
|
||||
DocGenerator []string `json:"docgenerator,omitempty"`
|
||||
EmailSender []string `json:"emailsender,omitempty"`
|
||||
ErrorConditionHandler []string `json:"errorconditionhandler,omitempty"`
|
||||
GridManager []string `json:"gridmanager,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
Info []string `json:"info,omitempty"`
|
||||
InfoMGR []string `json:"infomgr,omitempty"`
|
||||
Job []string `json:"job,omitempty"`
|
||||
Log []string `json:"log,omitempty"`
|
||||
Logo []string `json:"logo,omitempty"`
|
||||
Oauth []string `json:"oauth,omitempty"`
|
||||
Task []string `json:"task,omitempty"`
|
||||
UserManager []string `json:"usermanager,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
38
pkg/cloudbroker/apiaccess/set_default.go
Normal file
38
pkg/cloudbroker/apiaccess/set_default.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// SetDefaultRequest struct for setting default apiaccess group.
|
||||
type SetDefaultRequest struct {
|
||||
// APIAccess group ID
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
}
|
||||
|
||||
// SetDefault sets current apiaccess group default.
|
||||
func (a APIAccess) SetDefault(ctx context.Context, req SetDefaultRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/setDefault"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
43
pkg/cloudbroker/apiaccess/subtract.go
Normal file
43
pkg/cloudbroker/apiaccess/subtract.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"context"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// SubtractRequest struct for subtracting.
|
||||
type SubtractRequest struct {
|
||||
// ID of the API access group to subtract from. This group will contain the difference.
|
||||
MinuendID uint64 `url:"minuendId" json:"minuendId" validate:"required"`
|
||||
|
||||
// ID of the API access group which is subtracted. This group is unchanged.
|
||||
SubtrahendID uint64 `url:"subtrahendId" json:"subtrahendId" validate:"required"`
|
||||
}
|
||||
|
||||
// Subtract removes such APIs from MinuendID that match APIs from SubtrahendID.
|
||||
func (a APIAccess) Subtruct(ctx context.Context, req SubtractRequest) (*APIsEndpoints, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/subtract"
|
||||
|
||||
info := APIsEndpoints{}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
45
pkg/cloudbroker/apiaccess/union.go
Normal file
45
pkg/cloudbroker/apiaccess/union.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// UnionRequest struct for union.
|
||||
type UnionRequest struct {
|
||||
// Recipient apiaccess group ID
|
||||
// Required: true
|
||||
RecipientID uint64 `url:"recipientId" json:"recipientId" validate:"required"`
|
||||
|
||||
// Donor apiaccess group ID
|
||||
// Required: true
|
||||
DonorID uint64 `url:"donorId" json:"donorId" validate:"required"`
|
||||
}
|
||||
|
||||
// Union combines the API list of group #1 ("recipient") and group #2 ("donor"),
|
||||
// writing the result to group #1 and avoiding duplicates in the list
|
||||
func (a APIAccess) Union(ctx context.Context, req UnionRequest) (*APIsEndpoints, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/union"
|
||||
|
||||
info := APIsEndpoints{}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
60
pkg/cloudbroker/apiaccess/update.go
Normal file
60
pkg/cloudbroker/apiaccess/update.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateRequest struct for updating apis of apiaccess group.
|
||||
type UpdateRequest struct {
|
||||
// APIAccess group ID
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// APIs to remove from APIAccess group
|
||||
// Required: false
|
||||
APIs APIsEndpoints `url:"-" json:"-"`
|
||||
}
|
||||
|
||||
type wrapperUpdateRequest struct {
|
||||
UpdateRequest
|
||||
|
||||
APIString string `url:"apis"`
|
||||
}
|
||||
|
||||
// Update updates apis of apiaccess group.
|
||||
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/update"
|
||||
|
||||
reqWrapped := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
}
|
||||
|
||||
apiJSON, err := json.Marshal(&req.APIs)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
reqWrapped.APIString = string(apiJSON)
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
48
pkg/cloudbroker/apiaccess/user_list.go
Normal file
48
pkg/cloudbroker/apiaccess/user_list.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// UserListRequest struct for getting a list of users currently included in the specified group.
|
||||
type UserListRequest struct {
|
||||
// APIAccess group ID
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// UserList gets a list of users currently included in the specified group.
|
||||
func (a APIAccess) UserList(ctx context.Context, req UserListRequest) ([]string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/userList"
|
||||
|
||||
list := make([]string, 0)
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user