Skip to content

Commit

Permalink
WIP - changing computers
Browse files Browse the repository at this point in the history
  • Loading branch information
gabfelp committed Feb 17, 2023
1 parent bdc4058 commit a32e3ee
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 140 deletions.
1 change: 1 addition & 0 deletions cyral/data_source_cyral_regopolicy_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func dataSourceRegopolicyInstance() *schema.Resource {
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
},
},
},
Expand Down
67 changes: 37 additions & 30 deletions cyral/model_regopolicy_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,43 @@ type Scope struct {
RepoIds []string `json:"repoIds,omitempty"`
}

type ChangeInfo_ActorType int32

const (
ChangeInfo_USER ChangeInfo_ActorType = 0
ChangeInfo_API_CLIENT ChangeInfo_ActorType = 1
actorUser = "USER"
actorApiClient = "API_CLIENT"
)

type Category int32
func actorTypes() []string {
return []string{
actorUser,
actorApiClient,
}
}

const (
Category_UNKNOWN Category = 0
Category_SECURITY Category = 1
Category_GRANT Category = 2
Category_USER_DEFINED Category = 3
categoryTypeUnknown = "UNKNOWN"
categoryTypePredefined = "SECURITY"
categoryTypeCustom = "GRANT"
categoryUserDefined = "USER_DEFINED"
)

func categoryTypes() []string {
return []string{
categoryTypeUnknown,
categoryTypePredefined,
categoryTypeCustom,
categoryUserDefined,
}
}

type ChangeInfo struct {
Actor string `json:"actor,omitempty"`
ActorType ChangeInfo_ActorType `json:"actorType,omitempty"`
ActorType string `json:"actorType,omitempty"`
Timestamp *timestamppb.Timestamp `json:"timestamp,omitempty"`
}

type Key struct {
Id string `json:"id,omitempty"`
Category Category `json:"category,omitempty"`
Id string `json:"id,omitempty"`
Category string `json:"category,omitempty"`
}

func (pi *PolicyInstance) TagsAsInterface() []interface{} {
Expand All @@ -57,7 +69,7 @@ type PolicyInstance struct {

// used for 'data' in requests
type PolicyInstanceDataRequest struct {
Instance *PolicyInstance `json:"policyInstance,omitempty"`
Instance *PolicyInstance `json:"instance,omitempty"`
Duration string `json:"duration,omitempty"`
}

Expand All @@ -67,43 +79,38 @@ type ListPolicyInstancePartial struct {
TemplateId string `json:"templateId,omitempty"`
}

type InsertPolicyInstanceRequest struct {
Category Category `json:"category,omitempty"`
Data PolicyInstanceDataRequest `json:"data,omitempty"`
}
type InsertPolicyInstanceRequest PolicyInstanceDataRequest

type UpdatePolicyInstanceRequest struct {
Key Key `json:"key,omitempty"`
Data PolicyInstanceDataRequest `json:"data,omitempty"`
}
type UpdatePolicyInstanceRequest PolicyInstanceDataRequest

type DeletePolicyInstanceRequest struct {
Key Key `json:"key,omitempty"`
Id string `json:"id,omitempty"`
Category string `json:"category,omitempty"`
}

type ReadPolicyInstanceRequest struct {
Key Key `json:"key,omitempty"`
Id string `json:"id,omitempty"`
Category string `json:"category,omitempty"`
}

type ReadPolicyInstancesRequest struct {
Category Category `json:"category,omitempty"`
Category string `json:"category,omitempty"`
}

type InsertPolicyInstanceResponse struct {
Key Key `json:"key,omitempty"`
Id string `json:"id,omitempty"`
Category string `json:"category,omitempty"`
}

type UpdatePolicyInstanceResponse struct {
}

type DeletePolicyInstanceResponse struct {
instance PolicyInstance `json:"instance,omitempty"`
Instance PolicyInstance `json:"instance,omitempty"`
}

type ReadPolicyInstanceResponse struct {
instance PolicyInstance `json:"instance,omitempty"`
}
type ReadPolicyInstanceResponse PolicyInstance

type ReadPolicyInstancesResponse struct {
instances []ListPolicyInstancePartial `json:"instances,omitempty"`
Instances []ListPolicyInstancePartial `json:"instances,omitempty"`
}
2 changes: 2 additions & 0 deletions cyral/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func Provider() *schema.Provider {
"cyral_sidecar_cft_template": dataSourceSidecarCftTemplate(),
"cyral_sidecar_id": dataSourceSidecarID(),
"cyral_sidecar_instance_ids": dataSourceSidecarInstanceIDs(),
"cyral_regopolicy_instance": dataSourceRegopolicyInstance(),
},

ResourcesMap: map[string]*schema.Resource{
Expand All @@ -106,6 +107,7 @@ func Provider() *schema.Provider {
"cyral_integration_sumo_logic": resourceIntegrationSumoLogic(),
"cyral_policy": resourcePolicy(),
"cyral_policy_rule": resourcePolicyRule(),
"cyral_regopolicy_instance": resourceRegopolicyInstance(),
"cyral_repository": resourceRepository(),
"cyral_repository_binding": resourceRepositoryBinding(),
"cyral_repository_conf_analysis": resourceRepositoryConfAnalysis(),
Expand Down
Loading

0 comments on commit a32e3ee

Please sign in to comment.