Skip to content

Commit

Permalink
deleted to make it easy for git merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar López committed Dec 16, 2020
1 parent d8fdf8a commit 2ae0bd7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 1,926 deletions.
242 changes: 0 additions & 242 deletions client/v3/v3_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ type Service interface {
ListAllAccessControlPolicy(filter string) (*AccessControlPolicyListResponse, error)
UpdateAccessControlPolicy(uuid string, body *AccessControlPolicy) (*AccessControlPolicy, error)
DeleteAccessControlPolicy(uuid string) (*DeleteResponse, error)
GetProtectionRule(uuid string) (*ProtectionRuleResponse, error)
ListProtectionRules(getEntitiesRequest *DSMetadata) (*ProtectionRulesListResponse, error)
ListAllProtectionRules() (*ProtectionRulesListResponse, error)
CreateProtectionRule(request *ProtectionRuleInput) (*ProtectionRuleResponse, error)
UpdateProtectionRule(uuid string, body *ProtectionRuleInput) (*ProtectionRuleResponse, error)
DeleteProtectionRule(uuid string) (*DeleteResponse, error)
GetRecoveryPlan(uuid string) (*RecoveryPlanResponse, error)
ListRecoveryPlans(getEntitiesRequest *DSMetadata) (*RecoveryPlanListResponse, error)
ListAllRecoveryPlans() (*RecoveryPlanListResponse, error)
CreateRecoveryPlan(request *RecoveryPlanInput) (*RecoveryPlanResponse, error)
UpdateRecoveryPlan(uuid string, body *RecoveryPlanInput) (*RecoveryPlanResponse, error)
DeleteRecoveryPlan(uuid string) (*DeleteResponse, error)
}

/*CreateVM Creates a VM
Expand Down Expand Up @@ -1459,233 +1447,3 @@ func (op Operations) DeleteAccessControlPolicy(uuid string) (*DeleteResponse, er

return deleteResponse, op.client.Do(ctx, req, deleteResponse)
}

//GetProtectionRule ...
func (op Operations) GetProtectionRule(uuid string) (*ProtectionRuleResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/protection_rules/%s", uuid)
protectionRule := new(ProtectionRuleResponse)

req, err := op.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, err
}

return protectionRule, op.client.Do(ctx, req, protectionRule)
}

//ListProtectionRules ...
func (op Operations) ListProtectionRules(getEntitiesRequest *DSMetadata) (*ProtectionRulesListResponse, error) {
ctx := context.TODO()
path := "/protection_rules/list"

list := new(ProtectionRulesListResponse)

req, err := op.client.NewRequest(ctx, http.MethodPost, path, getEntitiesRequest)
if err != nil {
return nil, err
}

return list, op.client.Do(ctx, req, list)
}

// ListAllProtectionRules ...
func (op Operations) ListAllProtectionRules() (*ProtectionRulesListResponse, error) {
entities := make([]*ProtectionRuleResponse, 0)

resp, err := op.ListProtectionRules(&DSMetadata{
Kind: utils.StringPtr("protection_rule"),
Length: utils.Int64Ptr(itemsPerPage),
})
if err != nil {
return nil, err
}

totalEntities := utils.Int64Value(resp.Metadata.TotalMatches)
remaining := totalEntities
offset := utils.Int64Value(resp.Metadata.Offset)

if totalEntities > itemsPerPage {
for hasNext(&remaining) {
resp, err = op.ListProtectionRules(&DSMetadata{
Kind: utils.StringPtr("protection_rule"),
Length: utils.Int64Ptr(itemsPerPage),
Offset: utils.Int64Ptr(offset),
})

if err != nil {
return nil, err
}

entities = append(entities, resp.Entities...)

offset += itemsPerPage
log.Printf("[Debug] total=%d, remaining=%d, offset=%d len(entities)=%d\n", totalEntities, remaining, offset, len(entities))
}

resp.Entities = entities
}

return resp, nil
}

//CreateProtectionRule ...
func (op Operations) CreateProtectionRule(createRequest *ProtectionRuleInput) (*ProtectionRuleResponse, error) {
ctx := context.TODO()

req, err := op.client.NewRequest(ctx, http.MethodPost, "/protection_rules", createRequest)
protectionRuleResponse := new(ProtectionRuleResponse)

if err != nil {
return nil, err
}

return protectionRuleResponse, op.client.Do(ctx, req, protectionRuleResponse)
}

//UpdateProtectionRule ...
func (op Operations) UpdateProtectionRule(uuid string, body *ProtectionRuleInput) (*ProtectionRuleResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/protection_rules/%s", uuid)
req, err := op.client.NewRequest(ctx, http.MethodPut, path, body)
protectionRuleResponse := new(ProtectionRuleResponse)

if err != nil {
return nil, err
}

return protectionRuleResponse, op.client.Do(ctx, req, protectionRuleResponse)
}

//DeleteProtectionRule ...
func (op Operations) DeleteProtectionRule(uuid string) (*DeleteResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/protection_rules/%s", uuid)

req, err := op.client.NewRequest(ctx, http.MethodDelete, path, nil)
deleteResponse := new(DeleteResponse)

if err != nil {
return nil, err
}

return deleteResponse, op.client.Do(ctx, req, deleteResponse)
}

//GetRecoveryPlan ...
func (op Operations) GetRecoveryPlan(uuid string) (*RecoveryPlanResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/recovery_plans/%s", uuid)
RecoveryPlan := new(RecoveryPlanResponse)

req, err := op.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, err
}

return RecoveryPlan, op.client.Do(ctx, req, RecoveryPlan)
}

//ListRecoveryPlans ...
func (op Operations) ListRecoveryPlans(getEntitiesRequest *DSMetadata) (*RecoveryPlanListResponse, error) {
ctx := context.TODO()
path := "/recovery_plans/list"

list := new(RecoveryPlanListResponse)

req, err := op.client.NewRequest(ctx, http.MethodPost, path, getEntitiesRequest)
if err != nil {
return nil, err
}

return list, op.client.Do(ctx, req, list)
}

// ListAllRecoveryPlans ...
func (op Operations) ListAllRecoveryPlans() (*RecoveryPlanListResponse, error) {
entities := make([]*RecoveryPlanResponse, 0)

resp, err := op.ListRecoveryPlans(&DSMetadata{
Kind: utils.StringPtr("recovery_plan"),
Length: utils.Int64Ptr(itemsPerPage),
})
if err != nil {
return nil, err
}

totalEntities := utils.Int64Value(resp.Metadata.TotalMatches)
remaining := totalEntities
offset := utils.Int64Value(resp.Metadata.Offset)

if totalEntities > itemsPerPage {
for hasNext(&remaining) {
resp, err = op.ListRecoveryPlans(&DSMetadata{
Kind: utils.StringPtr("recovery_plan"),
Length: utils.Int64Ptr(itemsPerPage),
Offset: utils.Int64Ptr(offset),
})

if err != nil {
return nil, err
}

entities = append(entities, resp.Entities...)

offset += itemsPerPage
log.Printf("[Debug] total=%d, remaining=%d, offset=%d len(entities)=%d\n", totalEntities, remaining, offset, len(entities))
}

resp.Entities = entities
}

return resp, nil
}

//CreateRecoveryPlan ...
func (op Operations) CreateRecoveryPlan(createRequest *RecoveryPlanInput) (*RecoveryPlanResponse, error) {
ctx := context.TODO()

req, err := op.client.NewRequest(ctx, http.MethodPost, "/recovery_plans", createRequest)
RecoveryPlanResponse := new(RecoveryPlanResponse)

if err != nil {
return nil, err
}

return RecoveryPlanResponse, op.client.Do(ctx, req, RecoveryPlanResponse)
}

//UpdateRecoveryPlan ...
func (op Operations) UpdateRecoveryPlan(uuid string, body *RecoveryPlanInput) (*RecoveryPlanResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/recovery_plans/%s", uuid)
req, err := op.client.NewRequest(ctx, http.MethodPut, path, body)
RecoveryPlanResponse := new(RecoveryPlanResponse)

if err != nil {
return nil, err
}

return RecoveryPlanResponse, op.client.Do(ctx, req, RecoveryPlanResponse)
}

//DeleteRecoveryPlan ...
func (op Operations) DeleteRecoveryPlan(uuid string) (*DeleteResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/recovery_plans/%s", uuid)

req, err := op.client.NewRequest(ctx, http.MethodDelete, path, nil)
deleteResponse := new(DeleteResponse)

if err != nil {
return nil, err
}

return deleteResponse, op.client.Do(ctx, req, deleteResponse)
}
Loading

0 comments on commit 2ae0bd7

Please sign in to comment.