github.com/vmware/govmomi@v0.51.0/property/filter.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 property
     6  
     7  import (
     8  	"context"
     9  
    10  	"github.com/vmware/govmomi/vim25/methods"
    11  	"github.com/vmware/govmomi/vim25/soap"
    12  	"github.com/vmware/govmomi/vim25/types"
    13  )
    14  
    15  // Filter models the Filter managed object.
    16  //
    17  // For more information, see:
    18  // 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.
    19  type Filter struct {
    20  	roundTripper soap.RoundTripper
    21  	reference    types.ManagedObjectReference
    22  }
    23  
    24  func (f Filter) Reference() types.ManagedObjectReference {
    25  	return f.reference
    26  }
    27  
    28  // Destroy destroys this filter.
    29  //
    30  // This operation can be called explicitly, or it can take place implicitly when
    31  // the session that created the filter is closed.
    32  func (f *Filter) Destroy(ctx context.Context) error {
    33  	if _, err := methods.DestroyPropertyFilter(
    34  		ctx,
    35  		f.roundTripper,
    36  		&types.DestroyPropertyFilter{This: f.Reference()}); err != nil {
    37  
    38  		return err
    39  	}
    40  	f.reference = types.ManagedObjectReference{}
    41  	return nil
    42  }