func FromKey(client *govmomi.Client, dvsUUID, pgKey string) (*object.DistributedVirtualPortgroup, error) {
	dvsm := types.ManagedObjectReference{Type: "DistributedVirtualSwitchManager", Value: "DVSManager"}
	req := &types.DVSManagerLookupDvPortGroup{
		This:         dvsm,
		SwitchUuid:   dvsUUID,
		PortgroupKey: pgKey,
	}
	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
	defer cancel()
	resp, err := methods.DVSManagerLookupDvPortGroup(ctx, client, req)
	if err != nil {
		return nil, err
	}

	if resp.Returnval == nil {
		return nil, NewMissingPortGroupReferenceError(
			fmt.Sprintf(
				"portgroup lookup by key returned nil result for DVS UUID %q and portgroup key %q",
				dvsUUID,
				pgKey,
			),
		)
	}

	return FromMOID(client, resp.Returnval.Reference().Value)
}
func FromKey(client *govmomi.Client, dvsUUID, pgKey string) (*object.DistributedVirtualPortgroup, error) {
	dvsm := types.ManagedObjectReference{Type: "DistributedVirtualSwitchManager", Value: "DVSManager"}
	req := &types.DVSManagerLookupDvPortGroup{
		This:         dvsm,
		SwitchUuid:   dvsUUID,
		PortgroupKey: pgKey,
	}
	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
	defer cancel()
	resp, err := methods.DVSManagerLookupDvPortGroup(ctx, client, req)
	if err != nil {
		return nil, err
	}

	if resp.Returnval == nil {
		return nil, NewMissingPortGroupReferenceError(
			fmt.Sprintf(
				"portgroup lookup by key returned nil result for DVS UUID %q and portgroup key %q",
				dvsUUID,
				pgKey,
			),
		)
	}

	return FromMOID(client, resp.Returnval.Reference().Value)
}
func FromKey ( client * govmomi . Client , dvsUUID , pgKey string ) ( * object . DistributedVirtualPortgroup , error ) { dvsm := types . ManagedObjectReference { Type : " " , Value : " " } req := & types . DVSManagerLookupDvPortGroup { This : dvsm , SwitchUuid : dvsUUID , PortgroupKey : pgKey , } ctx , cancel := context . WithTimeout ( context . Background ( ) , provider . DefaultAPITimeout ) defer cancel ( ) resp , err := methods . DVSManagerLookupDvPortGroup ( ctx , client , req ) if err != nil { return nil , err } if resp . Returnval == nil { return nil , NewMissingPortGroupReferenceError ( fmt . Sprintf ( " " , dvsUUID , pgKey , ) , ) } return FromMOID ( client , resp . Returnval . Reference ( ) . Value ) }
// FromKey gets a portgroup object from its key.
FromKey gets a portgroup object from its key .