-
Notifications
You must be signed in to change notification settings - Fork 1
/
dlp_exact_data_match_lite.go
95 lines (75 loc) · 3.07 KB
/
dlp_exact_data_match_lite.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
package dlp_exact_data_match_lite
import (
"fmt"
"net/url"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/common"
)
const (
dlpEDMELiteEndpoint = "/dlpExactDataMatchSchemas/lite"
)
// Gets a list of active EDM templates (or EDM profiles) and their criteria, only.
type DLPEDMLite struct {
// The identifier (1-65519) for the EDM schema (i.e., EDM template) that is unique within the organization.
Schema SchemaIDNameExtension `json:"schema,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"`
}
type SchemaIDNameExtension struct {
// Identifier that uniquely identifies an entity
ID int `json:"ID,omitempty"`
// The configured name of the entity
Name string `json:"name,omitempty"`
// An external identifier used for an entity that is managed outside of ZIA.
// Examples include zpaServerGroup and zpaAppSegments.
// This field is not applicable to ZIA-managed entities.
ExternalID string `json:"externalId,omitempty"`
Extensions map[string]interface{} `json:"extensions,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"`
}
func GetBySchemaName(service *services.Service, schemaName string, activeOnly, fetchTokens bool) ([]DLPEDMLite, error) {
queryParameters := url.Values{}
queryParameters.Set("schemaName", schemaName)
if activeOnly {
queryParameters.Set("activeOnly", "true")
}
if fetchTokens {
queryParameters.Set("fetchTokens", "true")
}
endpoint := fmt.Sprintf("%s?%s", dlpEDMELiteEndpoint, queryParameters.Encode())
var edmData []DLPEDMLite
err := common.ReadAllPages(service.Client, endpoint, &edmData)
if err != nil {
return nil, err
}
return edmData, nil
}
func GetAllEDMSchema(service *services.Service, activeOnly, fetchTokens bool) ([]DLPEDMLite, error) {
queryParameters := url.Values{}
if activeOnly {
queryParameters.Set("activeOnly", "true")
}
if fetchTokens {
queryParameters.Set("fetchTokens", "true")
}
endpoint := dlpEDMELiteEndpoint
if len(queryParameters) > 0 {
endpoint += "?" + queryParameters.Encode()
}
var edmData []DLPEDMLite
err := common.ReadAllPages(service.Client, endpoint, &edmData)
return edmData, err
}