-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlp_exact_data_match.go
134 lines (99 loc) · 6.01 KB
/
dlp_exact_data_match.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package dlp_exact_data_match
import (
"fmt"
"net/url"
"strings"
"github.com/SecurityGeekIO/zscaler-sdk-go/v2/zia/services/common"
)
const (
dlpEDMSchemaEndpoint = "/dlpExactDataMatchSchemas"
)
type DLPEDMSchema struct {
// The identifier (1-65519) for the EDM schema (i.e., EDM template) that is unique within the organization.
SchemaID int `json:"schemaId,omitempty"`
// The unique identifer for the Index Tool that was used to create the EDM template. This attribute is ignored by PUT requests, but required for POST requests.
EDMClient *common.IDNameExtensions `json:"edmClient,omitempty"`
// The EDM schema (i.e., EDM template) name. This attribute is ignored by PUT requests, but required for POST requests.
ProjectName string `json:"projectName,omitempty"`
// The revision number of the CSV file upload to the Index Tool. This attribute is required by PUT requests.
Revision int `json:"revision,omitempty"`
// The generated filename, excluding the extention.
Filename string `json:"filename,omitempty"`
// The generated filename, excluding the extention.
OriginalFileName string `json:"originalFileName,omitempty"`
// The status of the EDM template's CSV file upload to the Index Tool. This attribute is required by PUT and POST requests.
FileUploadStatus string `json:"fileUploadStatus,omitempty"`
// The status of the EDM template's CSV file upload to the Index Tool. This attribute is required by PUT and POST requests.
SchemaStatus string `json:"schemaStatus,omitempty"`
// The total count of actual columns selected from the CSV file. This attribute is required by PUT and POST requests.
OrigColCount int `json:"origColCount,omitempty"`
// Timestamp when the EDM schema (i.e., EDM template) was last modified. Ignored if the request is PUT, POST, or DELETE.
LastModifiedTime int `json:"lastModifiedTime,omitempty"`
// The admin that modified the EDM template's schema last.
ModifiedBy *common.IDNameExtensions `json:"modifiedBy,omitempty"`
// The login name (or userid) the admin who created the EDM schema (i.e., EDM template). Ignored if the request is PUT, POST, or DELETE.
CreatedBy *common.IDNameExtensions `json:"createdBy,omitempty"`
// The total number of cells used by the EDM schema (i.e., EDM template).
CellsUsed int `json:"cellsUsed,omitempty"`
// Indicates the status of a specified EDM schema (i.e., EDM template). If this value is set to true, the schema is active and can be used by DLP dictionaries.
SchemaActive bool `json:"schemaActive,omitempty"`
// The total number of cells used by the EDM schema (i.e., EDM template).
SchedulePresent bool `json:"schedulePresent,omitempty"`
// Indicates the status of a specified EDM schema (i.e., EDM template). If this value is set to true, the schema is active and can be used by DLP dictionaries.
TokenList []TokenList `json:"tokenList,omitempty"`
// The schedule details, if present for the EDM schema (i.e., EDM template). Ignored if the request is PUT, POST, or DELETE.
Schedule Schedule `json:"schedule,omitempty"`
}
type TokenList struct {
// The token (i.e., criteria) name. This attribute is required by PUT and POST requests.
Name string `json:"name,omitempty"`
// The token (i.e., criteria) name. This attribute is required by PUT and POST requests.
Type string `json:"type,omitempty"`
// Indicates whether the token is a primary key.
PrimaryKey bool `json:"primaryKey,omitempty"`
// The column position for the token in the original CSV file uploaded to the Index Tool, starting from 1. This attribue required by PUT and POST requests.
OriginalColumn int `json:"originalColumn,omitempty"`
// The column position for the token in the hashed file, starting from 1.
HashfileColumnOrder int `json:"hashfileColumnOrder,omitempty"`
// The length of the column bitmap in the hashed file.
ColLengthBitmap int `json:"colLengthBitmap,omitempty"`
}
type Schedule struct {
// The schedule type for the EDM schema (i.e., EDM template), Monthly, Weekly, Daily, or None. This attribute is required by PUT and POST requests.
ScheduleType string `json:"scheduleType,omitempty"`
// The day of the month the EDM schema (i.e., EDM template) is scheduled for. This attribute is required by PUT and POST requests, and if the scheduleType is set to MONTHLY.
ScheduleDayOfMonth []string `json:"scheduleDayOfMonth,omitempty"`
// The day of the week the EDM schema (i.e., EDM template) is scheduled for. This attribute is required by PUT and POST requests, and if the scheduleType is set to WEEKLY.
ScheduleDayOfWeek []string `json:"scheduleDayOfWeek,omitempty"`
// The time of the day (in minutes) that the EDM schema (i.e., EDM template) is scheduled for. For example: at 3am= 180 mins. This attribute is required by PUT and POST requests.
ScheduleTime int `json:"scheduleTime,omitempty"`
// If set to true, the schedule for the EDM schema (i.e., EDM template) is temporarily in a disabled state. This attribute is required by PUT requests in order to disable or enable a schedule.
ScheduleDisabled bool `json:"scheduleDisabled,omitempty"`
}
func (service *Service) GetDLPEDMSchemaID(edmSchemaID int) (*DLPEDMSchema, error) {
var edmSchema DLPEDMSchema
err := service.Client.Read(fmt.Sprintf("%s/%d", dlpEDMSchemaEndpoint, edmSchemaID), &edmSchema)
if err != nil {
return nil, err
}
service.Client.Logger.Printf("[DEBUG]returning edm schema from Get: %d", edmSchema.SchemaID)
return &edmSchema, nil
}
func (service *Service) GetDLPEDMByName(edmSchemaName string) (*DLPEDMSchema, error) {
var edmSchema []DLPEDMSchema
err := common.ReadAllPages(service.Client, fmt.Sprintf("%s?name=%s", dlpEDMSchemaEndpoint, url.QueryEscape(edmSchemaName)), &edmSchema)
if err != nil {
return nil, err
}
for _, edmSchema := range edmSchema {
if strings.EqualFold(edmSchema.ProjectName, edmSchemaName) {
return &edmSchema, nil
}
}
return nil, fmt.Errorf("no edm schema found with name: %s", edmSchemaName)
}
func (service *Service) GetAll() ([]DLPEDMSchema, error) {
var edmData []DLPEDMSchema
err := common.ReadAllPages(service.Client, dlpEDMSchemaEndpoint, &edmData)
return edmData, err
}