Skip to content

Latest commit

 

History

History
276 lines (203 loc) · 15.5 KB

File metadata and controls

276 lines (203 loc) · 15.5 KB

Client.Governance.Data.Policies

Overview

Available Operations

  • Retrieve - Gets specified policy
  • Update - Updates an existing policy
  • List - Lists policies
  • Create - Creates new policy
  • Download - Downloads violations CSV for policy

Retrieve

Fetches the specified policy version, or the latest if no version is provided.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Governance.Data.Policies.Retrieve(ctx, "<id>", nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.GetDlpReportResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The id of the policy to fetch.
version *int64 The version of the policy to fetch. Each time a policy is updated, the older version is still stored. If this is left empty, the latest policy is fetched.
opts []operations.Option The options for this request.

Response

*operations.GetpolicyResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Update

Updates an existing policy.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Governance.Data.Policies.Update(ctx, "<id>", components.UpdateDlpReportRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.UpdateDlpReportResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The id of the policy to fetch.
updateDlpReportRequest components.UpdateDlpReportRequest ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.UpdatepolicyResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

List

Lists policies with filtering.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Governance.Data.Policies.List(ctx, nil, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.ListDlpReportsResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
autoHide *bool Filter to return reports with a given value of auto-hide.
frequency *string Filter to return reports with a given frequency.
opts []operations.Option The options for this request.

Response

*operations.ListpoliciesResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Create

Creates a new policy with specified specifications and returns its id.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Governance.Data.Policies.Create(ctx, components.CreateDlpReportRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.CreateDlpReportResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.CreateDlpReportRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreatepolicyResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Download

Downloads CSV violations report for a specific policy id. This does not support continuous policies.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Governance.Data.Policies.Download(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The id of the policy to download violations for.
opts []operations.Option The options for this request.

Response

*operations.DownloadpolicycsvResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*