github.com/vmware/go-vcloud-director/v2@v2.24.0/govcd/nsxt_segment_profiles.go (about)

     1  /*
     2   * Copyright 2023 VMware, Inc.  All rights reserved.  Licensed under the Apache v2 License.
     3   */
     4  
     5  package govcd
     6  
     7  import (
     8  	"net/url"
     9  
    10  	"github.com/vmware/go-vcloud-director/v2/types/v56"
    11  )
    12  
    13  const (
    14  	labelIpDiscoveryProfiles     = "IP Discovery Profiles"
    15  	labelMacDiscoveryProfiles    = "MAC Discovery Profiles"
    16  	labelSpoofGuardProfiles      = "Spoof Guard Profiles"
    17  	labelQosProfiles             = "QoS Profiles"
    18  	labelSegmentSecurityProfiles = "Segment Security Profiles"
    19  )
    20  
    21  // GetAllIpDiscoveryProfiles retrieves all IP Discovery Profiles configured in an NSX-T manager.
    22  // NSX-T manager ID (nsxTManagerRef.id), Org VDC ID (orgVdcId) or VDC Group ID (vdcGroupId) must be
    23  // supplied as a filter. Results can also be filtered by a single profile ID
    24  // (filter=nsxTManagerRef.id==nsxTManagerUrn;id==profileId).
    25  func (vcdClient *VCDClient) GetAllIpDiscoveryProfiles(queryParameters url.Values) ([]*types.NsxtSegmentProfileIpDiscovery, error) {
    26  	c := crudConfig{
    27  		endpoint:        types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointNsxtSegmentIpDiscoveryProfiles,
    28  		queryParameters: queryParameters,
    29  		entityLabel:     labelIpDiscoveryProfiles,
    30  	}
    31  	return getAllInnerEntities[types.NsxtSegmentProfileIpDiscovery](&vcdClient.Client, c)
    32  }
    33  
    34  func (vcdClient *VCDClient) GetIpDiscoveryProfileByName(name string, queryParameters url.Values) (*types.NsxtSegmentProfileIpDiscovery, error) {
    35  	apiFilteredEntities, err := vcdClient.GetAllIpDiscoveryProfiles(queryParameters) // API filtering by 'displayName' field is not supported
    36  	if err != nil {
    37  		return nil, err
    38  	}
    39  
    40  	return localFilterOneOrError(labelIpDiscoveryProfiles, apiFilteredEntities, "DisplayName", name)
    41  }
    42  
    43  // GetAllMacDiscoveryProfiles retrieves all MAC Discovery Profiles configured in an NSX-T manager.
    44  // NSX-T manager ID (nsxTManagerRef.id), Org VDC ID (orgVdcId) or VDC Group ID (vdcGroupId) must be
    45  // supplied as a filter. Results can also be filtered by a single profile ID
    46  // (filter=nsxTManagerRef.id==nsxTManagerUrn;id==profileId).
    47  func (vcdClient *VCDClient) GetAllMacDiscoveryProfiles(queryParameters url.Values) ([]*types.NsxtSegmentProfileMacDiscovery, error) {
    48  	c := crudConfig{
    49  		endpoint:        types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointNsxtSegmentMacDiscoveryProfiles,
    50  		queryParameters: queryParameters,
    51  		entityLabel:     labelMacDiscoveryProfiles,
    52  	}
    53  	return getAllInnerEntities[types.NsxtSegmentProfileMacDiscovery](&vcdClient.Client, c)
    54  }
    55  
    56  func (vcdClient *VCDClient) GetMacDiscoveryProfileByName(name string, queryParameters url.Values) (*types.NsxtSegmentProfileMacDiscovery, error) {
    57  	apiFilteredEntities, err := vcdClient.GetAllMacDiscoveryProfiles(queryParameters) // API filtering by 'displayName' field is not supported
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  
    62  	return localFilterOneOrError(labelMacDiscoveryProfiles, apiFilteredEntities, "DisplayName", name)
    63  }
    64  
    65  // GetAllSpoofGuardProfiles retrieves all Spoof Guard Profiles configured in an NSX-T manager.
    66  // NSX-T manager ID (nsxTManagerRef.id), Org VDC ID (orgVdcId) or VDC Group ID (vdcGroupId) must be
    67  // supplied as a filter. Results can also be filtered by a single profile ID
    68  // (filter=nsxTManagerRef.id==nsxTManagerUrn;id==profileId).
    69  func (vcdClient *VCDClient) GetAllSpoofGuardProfiles(queryParameters url.Values) ([]*types.NsxtSegmentProfileSegmentSpoofGuard, error) {
    70  	c := crudConfig{
    71  		endpoint:        types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointNsxtSegmentSpoofGuardProfiles,
    72  		queryParameters: queryParameters,
    73  		entityLabel:     labelSpoofGuardProfiles,
    74  	}
    75  	return getAllInnerEntities[types.NsxtSegmentProfileSegmentSpoofGuard](&vcdClient.Client, c)
    76  }
    77  
    78  func (vcdClient *VCDClient) GetSpoofGuardProfileByName(name string, queryParameters url.Values) (*types.NsxtSegmentProfileSegmentSpoofGuard, error) {
    79  	apiFilteredEntities, err := vcdClient.GetAllSpoofGuardProfiles(queryParameters) // API filtering by 'displayName' field is not supported
    80  	if err != nil {
    81  		return nil, err
    82  	}
    83  
    84  	return localFilterOneOrError(labelSpoofGuardProfiles, apiFilteredEntities, "DisplayName", name)
    85  }
    86  
    87  // GetAllQoSProfiles retrieves all QoS Profiles configured in an NSX-T manager.
    88  // NSX-T manager ID (nsxTManagerRef.id), Org VDC ID (orgVdcId) or VDC Group ID (vdcGroupId) must be
    89  // supplied as a filter. Results can also be filtered by a single profile ID
    90  // (filter=nsxTManagerRef.id==nsxTManagerUrn;id==profileId).
    91  func (vcdClient *VCDClient) GetAllQoSProfiles(queryParameters url.Values) ([]*types.NsxtSegmentProfileSegmentQosProfile, error) {
    92  	c := crudConfig{
    93  		endpoint:        types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointNsxtSegmentQosProfiles,
    94  		queryParameters: queryParameters,
    95  		entityLabel:     labelQosProfiles,
    96  	}
    97  	return getAllInnerEntities[types.NsxtSegmentProfileSegmentQosProfile](&vcdClient.Client, c)
    98  }
    99  
   100  func (vcdClient *VCDClient) GetQoSProfileByName(name string, queryParameters url.Values) (*types.NsxtSegmentProfileSegmentQosProfile, error) {
   101  	apiFilteredEntities, err := vcdClient.GetAllQoSProfiles(queryParameters) // API filtering by 'displayName' field is not supported
   102  	if err != nil {
   103  		return nil, err
   104  	}
   105  
   106  	return localFilterOneOrError(labelQosProfiles, apiFilteredEntities, "DisplayName", name)
   107  }
   108  
   109  // GetAllSegmentSecurityProfiles retrieves all Segment Security Profiles configured in an NSX-T manager.
   110  // NSX-T manager ID (nsxTManagerRef.id), Org VDC ID (orgVdcId) or VDC Group ID (vdcGroupId) must be
   111  // supplied as a filter. Results can also be filtered by a single profile ID
   112  // (filter=nsxTManagerRef.id==nsxTManagerUrn;id==profileId).
   113  func (vcdClient *VCDClient) GetAllSegmentSecurityProfiles(queryParameters url.Values) ([]*types.NsxtSegmentProfileSegmentSecurity, error) {
   114  	c := crudConfig{
   115  		endpoint:        types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointNsxtSegmentSecurityProfiles,
   116  		queryParameters: queryParameters,
   117  		entityLabel:     labelSegmentSecurityProfiles,
   118  	}
   119  	return getAllInnerEntities[types.NsxtSegmentProfileSegmentSecurity](&vcdClient.Client, c)
   120  }
   121  
   122  func (vcdClient *VCDClient) GetSegmentSecurityProfileByName(name string, queryParameters url.Values) (*types.NsxtSegmentProfileSegmentSecurity, error) {
   123  	apiFilteredEntities, err := vcdClient.GetAllSegmentSecurityProfiles(queryParameters) // API filtering by 'displayName' field is not supported
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  
   128  	return localFilterOneOrError(labelSegmentSecurityProfiles, apiFilteredEntities, "DisplayName", name)
   129  }