github.com/vmware/govmomi@v0.37.2/property/filter.go (about)

     1  /*
     2  Copyright (c) 2017-2024 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 property
    18  
    19  import (
    20  	"context"
    21  
    22  	"github.com/vmware/govmomi/vim25/methods"
    23  	"github.com/vmware/govmomi/vim25/soap"
    24  	"github.com/vmware/govmomi/vim25/types"
    25  )
    26  
    27  // Filter models the Filter managed object.
    28  //
    29  // For more information, see:
    30  // https://vdc-download.vmware.com/vmwb-repository/dcr-public/184bb3ba-6fa8-4574-a767-d0c96e2a38f4/ba9422ef-405c-47dd-8553-e11b619185b2/SDK/vsphere-ws/docs/ReferenceGuide/vmodl.query.PropertyCollector.Filter.html.
    31  type Filter struct {
    32  	roundTripper soap.RoundTripper
    33  	reference    types.ManagedObjectReference
    34  }
    35  
    36  func (f Filter) Reference() types.ManagedObjectReference {
    37  	return f.reference
    38  }
    39  
    40  // Destroy destroys this filter.
    41  //
    42  // This operation can be called explicitly, or it can take place implicitly when
    43  // the session that created the filter is closed.
    44  func (f *Filter) Destroy(ctx context.Context) error {
    45  	if _, err := methods.DestroyPropertyFilter(
    46  		ctx,
    47  		f.roundTripper,
    48  		&types.DestroyPropertyFilter{This: f.Reference()}); err != nil {
    49  
    50  		return err
    51  	}
    52  	f.reference = types.ManagedObjectReference{}
    53  	return nil
    54  }