github.com/vmware/govmomi@v0.51.0/object/authorization_manager_internal.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package object 6 7 import ( 8 "context" 9 10 "github.com/vmware/govmomi/vim25/soap" 11 "github.com/vmware/govmomi/vim25/types" 12 ) 13 14 type DisabledMethodRequest struct { 15 Method string `xml:"method"` 16 Reason string `xml:"reasonId"` 17 } 18 19 type disableMethodsRequest struct { 20 This types.ManagedObjectReference `xml:"_this"` 21 Entity []types.ManagedObjectReference `xml:"entity"` 22 Method []DisabledMethodRequest `xml:"method"` 23 Source string `xml:"sourceId"` 24 Scope bool `xml:"sessionScope,omitempty"` 25 } 26 27 type disableMethodsBody struct { 28 Req *disableMethodsRequest `xml:"urn:internalvim25 DisableMethods,omitempty"` 29 Res any `xml:"urn:vim25 DisableMethodsResponse,omitempty"` 30 Err *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` 31 } 32 33 func (b *disableMethodsBody) Fault() *soap.Fault { return b.Err } 34 35 func (m AuthorizationManager) DisableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []DisabledMethodRequest, source string) error { 36 var reqBody, resBody disableMethodsBody 37 38 reqBody.Req = &disableMethodsRequest{ 39 This: m.Reference(), 40 Entity: entity, 41 Method: method, 42 Source: source, 43 } 44 45 return m.Client().RoundTrip(ctx, &reqBody, &resBody) 46 } 47 48 type enableMethodsRequest struct { 49 This types.ManagedObjectReference `xml:"_this"` 50 Entity []types.ManagedObjectReference `xml:"entity"` 51 Method []string `xml:"method"` 52 Source string `xml:"sourceId"` 53 } 54 55 type enableMethodsBody struct { 56 Req *enableMethodsRequest `xml:"urn:internalvim25 EnableMethods,omitempty"` 57 Res any `xml:"urn:vim25 EnableMethodsResponse,omitempty"` 58 Err *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` 59 } 60 61 func (b *enableMethodsBody) Fault() *soap.Fault { return b.Err } 62 63 func (m AuthorizationManager) EnableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []string, source string) error { 64 var reqBody, resBody enableMethodsBody 65 66 reqBody.Req = &enableMethodsRequest{ 67 This: m.Reference(), 68 Entity: entity, 69 Method: method, 70 Source: source, 71 } 72 73 return m.Client().RoundTrip(ctx, &reqBody, &resBody) 74 }