github.com/vmware/govmomi@v0.43.0/eam/object/eam_object.go (about) 1 /* 2 Copyright (c) 2021 VMware, Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package object 18 19 import ( 20 "context" 21 "fmt" 22 23 "github.com/vmware/govmomi/eam" 24 "github.com/vmware/govmomi/eam/methods" 25 "github.com/vmware/govmomi/eam/types" 26 vim "github.com/vmware/govmomi/vim25/types" 27 ) 28 29 // EamObject contains the fields and functions common to all objects. 30 type EamObject struct { 31 c *eam.Client 32 r vim.ManagedObjectReference 33 } 34 35 func (m EamObject) String() string { 36 return fmt.Sprintf("%v", m.Reference()) 37 } 38 39 func (m EamObject) Reference() vim.ManagedObjectReference { 40 return m.r 41 } 42 43 func (m EamObject) Client() *eam.Client { 44 return m.c 45 } 46 47 func (m EamObject) AddIssue( 48 ctx context.Context, 49 issue types.BaseIssue) (types.BaseIssue, error) { 50 51 resp, err := methods.AddIssue(ctx, m.c, &types.AddIssue{ 52 This: m.r, 53 Issue: issue, 54 }) 55 if err != nil { 56 return nil, err 57 } 58 return resp.Returnval, nil 59 } 60 61 func (m EamObject) Issues( 62 ctx context.Context, 63 issueKeys ...int32) ([]types.BaseIssue, error) { 64 65 resp, err := methods.QueryIssue(ctx, m.c, &types.QueryIssue{ 66 This: m.r, 67 IssueKey: issueKeys, 68 }) 69 if err != nil { 70 return nil, err 71 } 72 return resp.Returnval, nil 73 } 74 75 func (m EamObject) Resolve( 76 ctx context.Context, 77 issueKeys []int32) ([]int32, error) { 78 79 resp, err := methods.Resolve(ctx, m.c, &types.Resolve{ 80 This: m.r, 81 IssueKey: issueKeys, 82 }) 83 if err != nil { 84 return nil, err 85 } 86 return resp.Returnval, nil 87 } 88 89 func (m EamObject) ResolveAll(ctx context.Context) error { 90 91 _, err := methods.ResolveAll(ctx, m.c, &types.ResolveAll{ 92 This: m.r, 93 }) 94 if err != nil { 95 return err 96 } 97 return nil 98 }