...
1 package iam
2
3 import (
4 "context"
5
6 "google.golang.org/api/cloudresourcemanager/v1"
7 "google.golang.org/api/iam/v1"
8 "google.golang.org/api/option"
9 )
10
11 type IAMService struct {
12 *iam.Service
13 }
14
15 type Component struct {
16 APIKey *iam.ServiceAccountKey
17 ServiceAccount *iam.ServiceAccount
18 PolicyMemberships *cloudresourcemanager.Policy
19 }
20
21
22 func CreateIAMClient(ctx context.Context, opts ...option.ClientOption) (*iam.Service, error) {
23 return iam.NewService(ctx, opts...)
24 }
25
26
27 func NewIAMService(ctx context.Context, opts ...option.ClientOption) (*IAMService, error) {
28 iamService, err := CreateIAMClient(ctx, opts...)
29 if err != nil {
30 return nil, err
31 }
32 return &IAMService{
33 iamService,
34 }, nil
35 }
36
37
38 func NewComponent(apiKey *iam.ServiceAccountKey, serviceAccount *iam.ServiceAccount, policyMembers *cloudresourcemanager.Policy) *Component {
39 return &Component{
40 APIKey: apiKey,
41 ServiceAccount: serviceAccount,
42 PolicyMemberships: policyMembers,
43 }
44 }
45
View as plain text