/
resource.go
55 lines (42 loc) · 1.39 KB
/
resource.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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package iamutil
import (
"context"
"github.com/hashicorp/go-gcp-common/gcputil"
)
// Resource handles constructing HTTP requests for getting and
// setting IAM policies.
type Resource interface {
GetIamPolicy(context.Context, *ApiHandle) (*Policy, error)
SetIamPolicy(context.Context, *ApiHandle, *Policy) (*Policy, error)
GetConfig() *RestResource
GetRelativeId() *gcputil.RelativeResourceName
}
type RestResource struct {
// Name is the base name of the resource
// i.e. for a GCE instance: "instance"
Name string
// TypeKey is the identifying path for the resource, or
// the RESTful resource identifier without resource IDs
// i.e. For a GCE instance: "projects/zones/instances"
TypeKey string
// Service is the name of the service this resource belongs to.
Service string
// IsPreferredVersion is true if this version of the API/resource is preferred.
IsPreferredVersion bool
// HTTP metadata for getting Policy data in GCP
GetMethod RestMethod
// HTTP metadata for setting Policy data in GCP
SetMethod RestMethod
// Ordered parameters to be replaced in method paths
Parameters []string
// Mapping of collection ids onto the parameter to be replaced
CollectionReplacementKeys map[string]string
}
type RestMethod struct {
HttpMethod string
BaseURL string
Path string
RequestFormat string
}