github.com/vmware/govmomi@v0.37.1/object/authorization_manager_internal.go (about) 1 /* 2 Copyright (c) 2017 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 22 "github.com/vmware/govmomi/vim25/soap" 23 "github.com/vmware/govmomi/vim25/types" 24 ) 25 26 type DisabledMethodRequest struct { 27 Method string `xml:"method"` 28 Reason string `xml:"reasonId"` 29 } 30 31 type disableMethodsRequest struct { 32 This types.ManagedObjectReference `xml:"_this"` 33 Entity []types.ManagedObjectReference `xml:"entity"` 34 Method []DisabledMethodRequest `xml:"method"` 35 Source string `xml:"sourceId"` 36 Scope bool `xml:"sessionScope,omitempty"` 37 } 38 39 type disableMethodsBody struct { 40 Req *disableMethodsRequest `xml:"urn:internalvim25 DisableMethods,omitempty"` 41 Res interface{} `xml:"urn:vim25 DisableMethodsResponse,omitempty"` 42 Err *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` 43 } 44 45 func (b *disableMethodsBody) Fault() *soap.Fault { return b.Err } 46 47 func (m AuthorizationManager) DisableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []DisabledMethodRequest, source string) error { 48 var reqBody, resBody disableMethodsBody 49 50 reqBody.Req = &disableMethodsRequest{ 51 This: m.Reference(), 52 Entity: entity, 53 Method: method, 54 Source: source, 55 } 56 57 return m.Client().RoundTrip(ctx, &reqBody, &resBody) 58 } 59 60 type enableMethodsRequest struct { 61 This types.ManagedObjectReference `xml:"_this"` 62 Entity []types.ManagedObjectReference `xml:"entity"` 63 Method []string `xml:"method"` 64 Source string `xml:"sourceId"` 65 } 66 67 type enableMethodsBody struct { 68 Req *enableMethodsRequest `xml:"urn:internalvim25 EnableMethods,omitempty"` 69 Res interface{} `xml:"urn:vim25 EnableMethodsResponse,omitempty"` 70 Err *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` 71 } 72 73 func (b *enableMethodsBody) Fault() *soap.Fault { return b.Err } 74 75 func (m AuthorizationManager) EnableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []string, source string) error { 76 var reqBody, resBody enableMethodsBody 77 78 reqBody.Req = &enableMethodsRequest{ 79 This: m.Reference(), 80 Entity: entity, 81 Method: method, 82 Source: source, 83 } 84 85 return m.Client().RoundTrip(ctx, &reqBody, &resBody) 86 }