v1.16.4
This commit is contained in:
dayterr
2026-09-18 16:49:20 +03:00
parent b39021820a
commit bf932e5ef9
161 changed files with 2375 additions and 227 deletions

View File

@@ -0,0 +1,43 @@
package stpolicy
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AddAccessReplicationProfileRequest struct to grant storage policy access to replication profile
type AddAccessReplicationProfileRequest struct {
// ID of replication profile
// Required: true
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
// ID of storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
}
// AddAccessReplicationProfile grants storage policy access to replication profile
func (sp StPolicy) AddAccessReplicationProfile(ctx context.Context, req AddAccessReplicationProfileRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/add_access_replication_profile"
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,77 @@
package stpolicy
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CalendarRequest struct for replication schedule calendar
type CalendarRequest struct {
// Weekly schedule
// Required: true
Weekly []string `url:"weekly" json:"weekly" validate:"required"`
}
// SchedulesRequest struct for replication profile schedule
type SchedulesRequest struct {
// Type of the schedule
// Required: true
Type string `url:"type" json:"type" validate:"required"`
// Name of the schedule
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Min interval
// Required: false
MINInterval uint64 `url:"min_interval,omitempty" json:"min_interval,omitempty"`
// Calendar of the schedule
// Required: false
Calendar []CalendarRequest `url:"calendar,omitempty" json:"calendar,omitempty" validate:"omitempty,dive"`
}
// CreateReplicationProfileRequest struct to create replication profile
type CreateReplicationProfileRequest struct {
// Name of the replication profile
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// Replication type
// Required: true
ReplicationType string `url:"replication_type" json:"replication_type" validate:"required"`
// Max copy rate
// Required: false
MAXCopyRate uint64 `url:"max_copy_rate,omitempty" json:"max_copy_rate,omitempty"`
// List of schedules
// Required: false
Schedules []SchedulesRequest `url:"schedules,omitempty" json:"schedules,omitempty" validate:"omitempty,dive"`
}
// CreateReplicationProfile creates a new replication profile
func (sp StPolicy) CreateReplicationProfile(ctx context.Context, req CreateReplicationProfileRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/create_replication_profile"
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}

View File

@@ -0,0 +1,39 @@
package stpolicy
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteReplicationProfileRequest struct to delete replication profile
type DeleteReplicationProfileRequest struct {
// ID of replication profile
// Required: true
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
}
// DeleteReplicationProfile deletes replication profile
func (sp StPolicy) DeleteReplicationProfile(ctx context.Context, req DeleteReplicationProfileRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/delete_replication_profile"
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,46 @@
package stpolicy
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetReplicationProfileRequest struct to get replication profile
type GetReplicationProfileRequest struct {
// ID of replication profile
// Required: true
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
}
// GetReplicationProfile gets replication profile as an InfoReplicationProfile struct
func (sp StPolicy) GetReplicationProfile(ctx context.Context, req GetReplicationProfileRequest) (*InfoReplicationProfile, error) {
res, err := sp.GetReplicationProfileRaw(ctx, req)
if err != nil {
return nil, err
}
info := InfoReplicationProfile{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetReplicationProfileRaw gets replication profile as an array of bytes
func (sp StPolicy) GetReplicationProfileRaw(ctx context.Context, req GetReplicationProfileRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/get_replication_profile"
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}

View File

@@ -0,0 +1,65 @@
package stpolicy
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListReplicationProfileRequest struct to get list of replication profiles
type ListReplicationProfileRequest struct {
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
// Search by replication profile ID
// Required: false
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
// Search by replication profile name
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Search by replication type
// Required: false
ReplicationType string `url:"replication_type,omitempty" json:"replication_type,omitempty"`
// Sort by one of supported fields, format ±<field>
// Required: false
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
}
// ListReplicationProfile gets list of replication profiles as a ListReplicationProfiles struct
func (sp StPolicy) ListReplicationProfile(ctx context.Context, req ListReplicationProfileRequest) (*ListReplicationProfiles, error) {
res, err := sp.ListReplicationProfileRaw(ctx, req)
if err != nil {
return nil, err
}
list := ListReplicationProfiles{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
}
// ListReplicationProfileRaw gets list of replication profiles as an array of bytes
func (sp StPolicy) ListReplicationProfileRaw(ctx context.Context, req ListReplicationProfileRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/list_replication_profile"
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}

View File

@@ -19,9 +19,12 @@ type InfoStoragePolicyWithID struct {
// Status of the storage policy
Status string `json:"status"`
// Max IOPS for the sotrage policy
// Max IOPS for the storage policy
LimitIOPS uint64 `json:"limit_iops"`
// ID of the replication profile
ReplicationProfileID uint64 `json:"replication_profile_id"`
// Which accounts and resource groups use the storage policy
Usage Usage `json:"usage"`
}
@@ -53,9 +56,12 @@ type ItemStoragePolicy struct {
// Status of the storage policy
Status string `json:"status"`
// Max IOPS for the sotrage policy
// Max IOPS for the storage policy
LimitIOPS uint64 `json:"limit_iops"`
// ID of the replication profile
ReplicationProfileID uint64 `json:"replication_profile_id"`
// Storage policy ID
StoragePolicyID uint64 `json:"storage_policy_id"`
@@ -85,6 +91,9 @@ type InfoStoragePolicy struct {
// Max IOPS for the storage policy
LimitIOPS uint64 `json:"limit_iops"`
// ID of the replication profile
ReplicationProfileID uint64 `json:"replication_profile_id"`
// Storage policy ID
StoragePolicyID uint64 `json:"storage_policy_id"`
@@ -115,3 +124,72 @@ type Usage struct {
// List of resource groups
Resgroups []uint64 `json:"resgroups"`
}
type ListReplicationProfiles struct {
// List
Data []ItemReplicationProfile `json:"data"`
// Entry Count
EntryCount uint64 `json:"entryCount"`
}
type ItemReplicationProfile struct {
// ID of the replication profile
ID uint64 `json:"id"`
// GUID
GUID uint64 `json:"guid"`
// Name of the replication profile
Name string `json:"name"`
// Replication types
ReplicationType []string `json:"replication_type"`
// Max copy rate
MAXCopyRate uint64 `json:"max_copy_rate"`
// List of schedules
Schedules ListSchedules `json:"schedules"`
}
type InfoReplicationProfile struct {
// ID of the replication profile
ID uint64 `json:"id"`
// GUID
GUID uint64 `json:"guid"`
// Name of the replication profile
Name string `json:"name"`
// Replication types
ReplicationType []string `json:"replication_type"`
// Max copy rate
MAXCopyRate uint64 `json:"max_copy_rate"`
// List of schedules
Schedules ListSchedules `json:"schedules"`
}
type ListSchedules []Schedule
type Schedule struct {
// Type of the schedule
Type string `json:"type"`
// Name of the schedule
Name string `json:"name"`
// Min interval
MINInterval uint64 `json:"min_interval"`
// Calendar of the schedule
Calendar Calendar `json:"calendar"`
}
type Calendar struct {
// Weekly schedule
Weekly map[string][]string `json:"weekly"`
}

View File

@@ -0,0 +1,43 @@
package stpolicy
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// RevokeAccessReplicationProfileRequest struct to revoke storage policy access to replication profile
type RevokeAccessReplicationProfileRequest struct {
// ID of replication profile
// Required: true
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
// ID of storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
}
// RevokeAccessReplicationProfile revokes storage policy access to replication profile
func (sp StPolicy) RevokeAccessReplicationProfile(ctx context.Context, req RevokeAccessReplicationProfileRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/revoke_access_replication_profile"
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -0,0 +1,70 @@
package stpolicy
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ConfigRequest struct for replication profile config
type ConfigRequest struct {
// New name of the replication profile
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// New replication type
// Required: false
ReplicationType string `url:"replication_type,omitempty" json:"replication_type,omitempty"`
// New max copy rate
// Required: false
MAXCopyRate uint64 `url:"max_copy_rate,omitempty" json:"max_copy_rate,omitempty"`
// New list of schedules
// Required: false
Schedules []SchedulesRequest `url:"schedules,omitempty" json:"schedules,omitempty" validate:"omitempty,dive"`
}
// UpdateReplicationProfileRequest struct to update replication profile
type UpdateReplicationProfileRequest struct {
// ID of replication profile
// Required: true
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
// Config of the replication profile
// Required: true
Config []ConfigRequest `url:"config" json:"config" validate:"required,dive"`
}
// UpdateReplicationProfile updates replication profile
func (sp StPolicy) UpdateReplicationProfile(ctx context.Context, req UpdateReplicationProfileRequest) (*InfoReplicationProfile, error) {
res, err := sp.UpdateReplicationProfileRaw(ctx, req)
if err != nil {
return nil, err
}
info := InfoReplicationProfile{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// UpdateReplicationProfileRaw updates replication profile and returns result as an array of bytes
func (sp StPolicy) UpdateReplicationProfileRaw(ctx context.Context, req UpdateReplicationProfileRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/update_replication_profile"
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
return res, err
}