diff --git a/ibm/service/vpc/data_source_ibm_is_bare_metal_servers.go b/ibm/service/vpc/data_source_ibm_is_bare_metal_servers.go index c50e022ed5..7ba0fe84b1 100644 --- a/ibm/service/vpc/data_source_ibm_is_bare_metal_servers.go +++ b/ibm/service/vpc/data_source_ibm_is_bare_metal_servers.go @@ -27,7 +27,46 @@ func DataSourceIBMIsBareMetalServers() *schema.Resource { ReadContext: dataSourceIBMISBareMetalServersRead, Schema: map[string]*schema.Schema{ - + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this bare metal server belongs to", + }, + "vpc": { + Type: schema.TypeString, + Optional: true, + Description: "The vpc ID this bare metal server is in", + }, + "vpc_name": { + Type: schema.TypeString, + Optional: true, + Description: "The vpc name this bare metal server is in", + }, + "vpc_crn": { + Type: schema.TypeString, + Optional: true, + Description: "The vpc CRN this bare metal server is in", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the bare metal server", + }, + "network_interfaces_subnet": { + Type: schema.TypeString, + Optional: true, + Description: "The ID of the subnet of the bare metal server network interfaces", + }, + "network_interfaces_subnet_crn": { + Type: schema.TypeString, + Optional: true, + Description: "The crn of the subnet of the bare metal server network interfaces", + }, + "network_interfaces_subnet_name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the subnet of the bare metal server network interfaces", + }, isBareMetalServers: { Type: schema.TypeList, Description: "List of Bare Metal Servers", @@ -386,8 +425,42 @@ func dataSourceIBMISBareMetalServersRead(context context.Context, d *schema.Reso } start := "" allrecs := []vpcv1.BareMetalServer{} + + listBareMetalServersOptions := &vpcv1.ListBareMetalServersOptions{} + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + listBareMetalServersOptions.ResourceGroupID = &resGroup + } + if nameintf, ok := d.GetOk("name"); ok { + name := nameintf.(string) + listBareMetalServersOptions.Name = &name + } + if vpcIntf, ok := d.GetOk("vpc"); ok { + vpcid := vpcIntf.(string) + listBareMetalServersOptions.VPCID = &vpcid + } + if vpcNameIntf, ok := d.GetOk("vpc_name"); ok { + vpcName := vpcNameIntf.(string) + listBareMetalServersOptions.VPCName = &vpcName + } + if vpcCrnIntf, ok := d.GetOk("vpc_crn"); ok { + vpcCrn := vpcCrnIntf.(string) + listBareMetalServersOptions.VPCCRN = &vpcCrn + } + if subnetIntf, ok := d.GetOk("network_interfaces_subnet"); ok { + subnetId := subnetIntf.(string) + listBareMetalServersOptions.NetworkInterfacesSubnetID = &subnetId + } + if subnetNameIntf, ok := d.GetOk("network_interfaces_subnet_name"); ok { + subnetName := subnetNameIntf.(string) + listBareMetalServersOptions.NetworkInterfacesSubnetName = &subnetName + } + if subnetCrnIntf, ok := d.GetOk("network_interfaces_subnet_crn"); ok { + subnetCrn := subnetCrnIntf.(string) + listBareMetalServersOptions.NetworkInterfacesSubnetCRN = &subnetCrn + } for { - listBareMetalServersOptions := &vpcv1.ListBareMetalServersOptions{} + if start != "" { listBareMetalServersOptions.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_dedicated_host.go b/ibm/service/vpc/data_source_ibm_is_dedicated_host.go index 4aade0f15c..8ebf02565a 100644 --- a/ibm/service/vpc/data_source_ibm_is_dedicated_host.go +++ b/ibm/service/vpc/data_source_ibm_is_dedicated_host.go @@ -350,126 +350,126 @@ func dataSourceIbmIsDedicatedHostRead(context context.Context, d *schema.Resourc resgrpidstr := resgrpid.(string) listDedicatedHostsOptions.ResourceGroupID = &resgrpidstr } + name := d.Get("name").(string) + listDedicatedHostsOptions.Name = &name dedicatedHostCollection, response, err := vpcClient.ListDedicatedHostsWithContext(context, listDedicatedHostsOptions) if err != nil { log.Printf("[DEBUG] ListDedicatedHostsWithContext failed %s\n%s", err, response) return diag.FromErr(err) } - name := d.Get("name").(string) + if len(dedicatedHostCollection.DedicatedHosts) != 0 { dedicatedHost := vpcv1.DedicatedHost{} - for _, data := range dedicatedHostCollection.DedicatedHosts { - if *data.Name == name { - dedicatedHost = data - d.SetId(*dedicatedHost.ID) - - if err = d.Set("available_memory", dedicatedHost.AvailableMemory); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting available_memory: %s", err)) - } - - if dedicatedHost.AvailableVcpu != nil { - err = d.Set("available_vcpu", dataSourceDedicatedHostFlattenAvailableVcpu(*dedicatedHost.AvailableVcpu)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting available_vcpu %s", err)) - } - } - if err = d.Set("created_at", dedicatedHost.CreatedAt.String()); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) - } - if err = d.Set("crn", dedicatedHost.CRN); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) - } - accesstags, err := flex.GetGlobalTagsUsingCRN(meta, *dedicatedHost.CRN, "", isDedicatedHostAccessTagType) - if err != nil { - log.Printf( - "Error on get of resource dedicated host (%s) access tags: %s", d.Id(), err) - } - d.Set(isDedicatedHostAccessTags, accesstags) - if dedicatedHost.Disks != nil { - err = d.Set("disks", dataSourceDedicatedHostFlattenDisks(dedicatedHost.Disks)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting disks %s", err)) - } - } - if dedicatedHost.Group != nil { - err = d.Set("host_group", *dedicatedHost.Group.ID) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting group %s", err)) - } - } - if err = d.Set("href", dedicatedHost.Href); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting href: %s", err)) - } - if err = d.Set("instance_placement_enabled", dedicatedHost.InstancePlacementEnabled); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting instance_placement_enabled: %s", err)) - } - - if dedicatedHost.Instances != nil { - err = d.Set("instances", dataSourceDedicatedHostFlattenInstances(dedicatedHost.Instances)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting instances %s", err)) - } - } - if err = d.Set("lifecycle_state", dedicatedHost.LifecycleState); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting lifecycle_state: %s", err)) - } - if err = d.Set("memory", dedicatedHost.Memory); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting memory: %s", err)) - } - if err = d.Set("name", dedicatedHost.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) - } - - if dedicatedHost.Profile != nil { - err = d.Set("profile", dataSourceDedicatedHostFlattenProfile(*dedicatedHost.Profile)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting profile %s", err)) - } - } - if err = d.Set("provisionable", dedicatedHost.Provisionable); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting provisionable: %s", err)) - } - - if dedicatedHost.ResourceGroup != nil { - err = d.Set("resource_group", *dedicatedHost.ResourceGroup.ID) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group %s", err)) - } - } - if err = d.Set("resource_type", dedicatedHost.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_type: %s", err)) - } - if err = d.Set("socket_count", dedicatedHost.SocketCount); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting socket_count: %s", err)) - } - if err = d.Set("state", dedicatedHost.State); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting state: %s", err)) - } - - if dedicatedHost.SupportedInstanceProfiles != nil { - err = d.Set("supported_instance_profiles", dataSourceDedicatedHostFlattenSupportedInstanceProfiles(dedicatedHost.SupportedInstanceProfiles)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting supported_instance_profiles %s", err)) - } - } - - if dedicatedHost.Vcpu != nil { - err = d.Set("vcpu", dataSourceDedicatedHostFlattenVcpu(*dedicatedHost.Vcpu)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting vcpu %s", err)) - } - } - - if dedicatedHost.Zone != nil { - err = d.Set("zone", *dedicatedHost.Zone.Name) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting zone %s", err)) - } - } - - return nil + + dedicatedHost = dedicatedHostCollection.DedicatedHosts[0] + d.SetId(*dedicatedHost.ID) + + if err = d.Set("available_memory", dedicatedHost.AvailableMemory); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting available_memory: %s", err)) + } + + if dedicatedHost.AvailableVcpu != nil { + err = d.Set("available_vcpu", dataSourceDedicatedHostFlattenAvailableVcpu(*dedicatedHost.AvailableVcpu)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting available_vcpu %s", err)) + } + } + if err = d.Set("created_at", dedicatedHost.CreatedAt.String()); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + } + if err = d.Set("crn", dedicatedHost.CRN); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) + } + accesstags, err := flex.GetGlobalTagsUsingCRN(meta, *dedicatedHost.CRN, "", isDedicatedHostAccessTagType) + if err != nil { + log.Printf( + "Error on get of resource dedicated host (%s) access tags: %s", d.Id(), err) + } + d.Set(isDedicatedHostAccessTags, accesstags) + if dedicatedHost.Disks != nil { + err = d.Set("disks", dataSourceDedicatedHostFlattenDisks(dedicatedHost.Disks)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting disks %s", err)) + } + } + if dedicatedHost.Group != nil { + err = d.Set("host_group", *dedicatedHost.Group.ID) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting group %s", err)) } } + if err = d.Set("href", dedicatedHost.Href); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting href: %s", err)) + } + if err = d.Set("instance_placement_enabled", dedicatedHost.InstancePlacementEnabled); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting instance_placement_enabled: %s", err)) + } + + if dedicatedHost.Instances != nil { + err = d.Set("instances", dataSourceDedicatedHostFlattenInstances(dedicatedHost.Instances)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting instances %s", err)) + } + } + if err = d.Set("lifecycle_state", dedicatedHost.LifecycleState); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting lifecycle_state: %s", err)) + } + if err = d.Set("memory", dedicatedHost.Memory); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting memory: %s", err)) + } + if err = d.Set("name", dedicatedHost.Name); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) + } + + if dedicatedHost.Profile != nil { + err = d.Set("profile", dataSourceDedicatedHostFlattenProfile(*dedicatedHost.Profile)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting profile %s", err)) + } + } + if err = d.Set("provisionable", dedicatedHost.Provisionable); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting provisionable: %s", err)) + } + + if dedicatedHost.ResourceGroup != nil { + err = d.Set("resource_group", *dedicatedHost.ResourceGroup.ID) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group %s", err)) + } + } + if err = d.Set("resource_type", dedicatedHost.ResourceType); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_type: %s", err)) + } + if err = d.Set("socket_count", dedicatedHost.SocketCount); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting socket_count: %s", err)) + } + if err = d.Set("state", dedicatedHost.State); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting state: %s", err)) + } + + if dedicatedHost.SupportedInstanceProfiles != nil { + err = d.Set("supported_instance_profiles", dataSourceDedicatedHostFlattenSupportedInstanceProfiles(dedicatedHost.SupportedInstanceProfiles)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting supported_instance_profiles %s", err)) + } + } + + if dedicatedHost.Vcpu != nil { + err = d.Set("vcpu", dataSourceDedicatedHostFlattenVcpu(*dedicatedHost.Vcpu)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting vcpu %s", err)) + } + } + + if dedicatedHost.Zone != nil { + err = d.Set("zone", *dedicatedHost.Zone.Name) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting zone %s", err)) + } + } + + return nil + } return diag.FromErr(fmt.Errorf("[ERROR] No Dedicated Host found with name %s", name)) } diff --git a/ibm/service/vpc/data_source_ibm_is_dedicated_host_group.go b/ibm/service/vpc/data_source_ibm_is_dedicated_host_group.go index 95b61b04fb..d0ee6a88d8 100644 --- a/ibm/service/vpc/data_source_ibm_is_dedicated_host_group.go +++ b/ibm/service/vpc/data_source_ibm_is_dedicated_host_group.go @@ -143,74 +143,70 @@ func dataSourceIbmIsDedicatedHostGroupRead(context context.Context, d *schema.Re } listDedicatedHostGroupsOptions := &vpcv1.ListDedicatedHostGroupsOptions{} - + name := d.Get("name").(string) + listDedicatedHostGroupsOptions.Name = &name dedicatedHostGroupCollection, response, err := vpcClient.ListDedicatedHostGroupsWithContext(context, listDedicatedHostGroupsOptions) if err != nil { log.Printf("[DEBUG] ListDedicatedHostGroupsWithContext failed %s\n%s", err, response) return diag.FromErr(err) } - name := d.Get("name").(string) - if len(dedicatedHostGroupCollection.Groups) != 0 { - dedicatedHostGroup := vpcv1.DedicatedHostGroup{} - for _, data := range dedicatedHostGroupCollection.Groups { - if *data.Name == name { - dedicatedHostGroup = data - d.SetId(*dedicatedHostGroup.ID) - if err = d.Set("class", dedicatedHostGroup.Class); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting class: %s", err)) - } - if dedicatedHostGroup.CreatedAt != nil { - if err = d.Set("created_at", dedicatedHostGroup.CreatedAt.String()); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) - } - } + dedicatedHostGroup := dedicatedHostGroupCollection.Groups[0] - if err = d.Set("crn", dedicatedHostGroup.CRN); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) - } + d.SetId(*dedicatedHostGroup.ID) + if err = d.Set("class", dedicatedHostGroup.Class); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting class: %s", err)) + } + if dedicatedHostGroup.CreatedAt != nil { + if err = d.Set("created_at", dedicatedHostGroup.CreatedAt.String()); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) + } + } - if dedicatedHostGroup.DedicatedHosts != nil { - err = d.Set("dedicated_hosts", dataSourceDedicatedHostGroupFlattenDedicatedHosts(dedicatedHostGroup.DedicatedHosts)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting dedicated_hosts %s", err)) - } - } - if err = d.Set("family", dedicatedHostGroup.Family); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting family: %s", err)) - } - if err = d.Set("href", dedicatedHostGroup.Href); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting href: %s", err)) - } + if err = d.Set("crn", dedicatedHostGroup.CRN); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting crn: %s", err)) + } - if dedicatedHostGroup.ResourceGroup != nil { - err = d.Set("resource_group", *dedicatedHostGroup.ResourceGroup.ID) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group %s", err)) - } - } - if err = d.Set("resource_type", dedicatedHostGroup.ResourceType); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_type: %s", err)) - } + if dedicatedHostGroup.DedicatedHosts != nil { + err = d.Set("dedicated_hosts", dataSourceDedicatedHostGroupFlattenDedicatedHosts(dedicatedHostGroup.DedicatedHosts)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting dedicated_hosts %s", err)) + } + } + if err = d.Set("family", dedicatedHostGroup.Family); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting family: %s", err)) + } + if err = d.Set("href", dedicatedHostGroup.Href); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting href: %s", err)) + } - if dedicatedHostGroup.SupportedInstanceProfiles != nil { - err = d.Set("supported_instance_profiles", dataSourceDedicatedHostGroupFlattenSupportedInstanceProfiles(dedicatedHostGroup.SupportedInstanceProfiles)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting supported_instance_profiles %s", err)) - } - } + if dedicatedHostGroup.ResourceGroup != nil { + err = d.Set("resource_group", *dedicatedHostGroup.ResourceGroup.ID) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_group %s", err)) + } + } + if err = d.Set("resource_type", dedicatedHostGroup.ResourceType); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting resource_type: %s", err)) + } - if dedicatedHostGroup.Zone != nil { - err = d.Set("zone", *dedicatedHostGroup.Zone.Name) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting zone %s", err)) - } - } - return nil + if dedicatedHostGroup.SupportedInstanceProfiles != nil { + err = d.Set("supported_instance_profiles", dataSourceDedicatedHostGroupFlattenSupportedInstanceProfiles(dedicatedHostGroup.SupportedInstanceProfiles)) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting supported_instance_profiles %s", err)) } } + + if dedicatedHostGroup.Zone != nil { + err = d.Set("zone", *dedicatedHostGroup.Zone.Name) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting zone %s", err)) + } + } + return nil + } return diag.FromErr(fmt.Errorf("[ERROR] No Dedicated Host Group found with name %s", name)) } diff --git a/ibm/service/vpc/data_source_ibm_is_dedicated_host_groups.go b/ibm/service/vpc/data_source_ibm_is_dedicated_host_groups.go index 414a0fb4d2..59475a34da 100644 --- a/ibm/service/vpc/data_source_ibm_is_dedicated_host_groups.go +++ b/ibm/service/vpc/data_source_ibm_is_dedicated_host_groups.go @@ -22,6 +22,21 @@ func DataSourceIbmIsDedicatedHostGroups() *schema.Resource { ReadContext: dataSourceIbmIsDedicatedHostGroupsRead, Schema: map[string]*schema.Schema{ + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this dedicated host group belongs to", + }, + "zone": { + Type: schema.TypeString, + Optional: true, + Description: "The zone name this dedicated host group is in", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the dedicated host group", + }, "host_groups": { Type: schema.TypeList, Computed: true, @@ -164,6 +179,19 @@ func dataSourceIbmIsDedicatedHostGroupsRead(context context.Context, d *schema.R } listDedicatedHostGroupsOptions := &vpcv1.ListDedicatedHostGroupsOptions{} + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + listDedicatedHostGroupsOptions.ResourceGroupID = &resGroup + } + if zoneintf, ok := d.GetOk("zone"); ok { + zoneName := zoneintf.(string) + listDedicatedHostGroupsOptions.ZoneName = &zoneName + } + if nameintf, ok := d.GetOk("name"); ok { + name := nameintf.(string) + listDedicatedHostGroupsOptions.Name = &name + } + start := "" allrecs := []vpcv1.DedicatedHostGroup{} for { diff --git a/ibm/service/vpc/data_source_ibm_is_dedicated_hosts.go b/ibm/service/vpc/data_source_ibm_is_dedicated_hosts.go index bcec793ae4..d0eeab8093 100644 --- a/ibm/service/vpc/data_source_ibm_is_dedicated_hosts.go +++ b/ibm/service/vpc/data_source_ibm_is_dedicated_hosts.go @@ -27,6 +27,21 @@ func DataSourceIbmIsDedicatedHosts() *schema.Resource { Optional: true, Description: "The unique identifier of the dedicated host group this dedicated host belongs to", }, + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this dedicated host belongs to", + }, + "zone": { + Type: schema.TypeString, + Optional: true, + Description: "The zone name this dedicated host is in", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the dedicated host", + }, "dedicated_hosts": { Type: schema.TypeList, Computed: true, @@ -372,6 +387,18 @@ func dataSourceIbmIsDedicatedHostsRead(context context.Context, d *schema.Resour hostgroupid := hostgroupintf.(string) listDedicatedHostsOptions.DedicatedHostGroupID = &hostgroupid } + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + listDedicatedHostsOptions.ResourceGroupID = &resGroup + } + if zoneintf, ok := d.GetOk("zone"); ok { + zoneName := zoneintf.(string) + listDedicatedHostsOptions.ZoneName = &zoneName + } + if nameintf, ok := d.GetOk("name"); ok { + name := nameintf.(string) + listDedicatedHostsOptions.Name = &name + } start := "" allrecs := []vpcv1.DedicatedHost{} for { diff --git a/ibm/service/vpc/data_source_ibm_is_floating_ips.go b/ibm/service/vpc/data_source_ibm_is_floating_ips.go index 1c35fe1174..b37d86d3cd 100644 --- a/ibm/service/vpc/data_source_ibm_is_floating_ips.go +++ b/ibm/service/vpc/data_source_ibm_is_floating_ips.go @@ -22,6 +22,11 @@ func DataSourceIBMIsFloatingIps() *schema.Resource { ReadContext: dataSourceIBMIsFloatingIpsRead, Schema: map[string]*schema.Schema{ + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this floating ips belongs to", + }, "name": { Type: schema.TypeString, Optional: true, @@ -219,8 +224,13 @@ func dataSourceIBMIsFloatingIpsRead(context context.Context, d *schema.ResourceD } start := "" allFloatingIPs := []vpcv1.FloatingIP{} + floatingIPOptions := &vpcv1.ListFloatingIpsOptions{} + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + floatingIPOptions.ResourceGroupID = &resGroup + } for { - floatingIPOptions := &vpcv1.ListFloatingIpsOptions{} + if start != "" { floatingIPOptions.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_flow_logs.go b/ibm/service/vpc/data_source_ibm_is_flow_logs.go index 25e4b0eedd..7b48ab91c1 100644 --- a/ibm/service/vpc/data_source_ibm_is_flow_logs.go +++ b/ibm/service/vpc/data_source_ibm_is_flow_logs.go @@ -22,7 +22,41 @@ func DataSourceIBMISFlowLogs() *schema.Resource { Read: dataSourceIBMISFlowLogsRead, Schema: map[string]*schema.Schema{ - + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this flow log belongs to", + }, + "vpc": { + Type: schema.TypeString, + Optional: true, + Description: "The vpc ID this flow log is in", + }, + "vpc_name": { + Type: schema.TypeString, + Optional: true, + Description: "The vpc name this flow log is in", + }, + "vpc_crn": { + Type: schema.TypeString, + Optional: true, + Description: "The vpc CRN this flow log is in", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the flow log ", + }, + "target": { + Type: schema.TypeString, + Optional: true, + Description: "The target id of the flow log ", + }, + "target_resource_type": { + Type: schema.TypeString, + Optional: true, + Description: "The target resource type of the flow log ", + }, isFlowLogs: { Type: schema.TypeList, Description: "Collection of flow log collectors", @@ -114,8 +148,37 @@ func dataSourceIBMISFlowLogsRead(d *schema.ResourceData, meta interface{}) error start := "" allrecs := []vpcv1.FlowLogCollector{} + listOptions := &vpcv1.ListFlowLogCollectorsOptions{} + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + listOptions.ResourceGroupID = &resGroup + } + if nameintf, ok := d.GetOk("name"); ok { + name := nameintf.(string) + listOptions.Name = &name + } + if vpcIntf, ok := d.GetOk("vpc"); ok { + vpcid := vpcIntf.(string) + listOptions.VPCID = &vpcid + } + if vpcNameIntf, ok := d.GetOk("vpc_name"); ok { + vpcName := vpcNameIntf.(string) + listOptions.VPCName = &vpcName + } + if vpcCrnIntf, ok := d.GetOk("vpc_crn"); ok { + vpcCrn := vpcCrnIntf.(string) + listOptions.VPCCRN = &vpcCrn + } + if targetIntf, ok := d.GetOk("target"); ok { + target := targetIntf.(string) + listOptions.TargetID = &target + } + if targetTypeIntf, ok := d.GetOk("target_resource_type"); ok { + targetType := targetTypeIntf.(string) + listOptions.TargetResourceType = &targetType + } for { - listOptions := &vpcv1.ListFlowLogCollectorsOptions{} + if start != "" { listOptions.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_network_acl_rules.go b/ibm/service/vpc/data_source_ibm_is_network_acl_rules.go index 279dcdc32c..779db4232a 100644 --- a/ibm/service/vpc/data_source_ibm_is_network_acl_rules.go +++ b/ibm/service/vpc/data_source_ibm_is_network_acl_rules.go @@ -22,6 +22,11 @@ func DataSourceIBMISNetworkACLRules() *schema.Resource { Read: dataSourceIBMISNetworkACLRulesRead, Schema: map[string]*schema.Schema{ + "direction": { + Type: schema.TypeString, + Optional: true, + Description: "The direction of the rules to filter", + }, isNwACLID: { Type: schema.TypeString, Required: true, @@ -185,10 +190,15 @@ func networkACLRulesList(d *schema.ResourceData, meta interface{}, nwACLID strin } start := "" allrecs := []vpcv1.NetworkACLRuleItemIntf{} + listNetworkACLRulesOptions := &vpcv1.ListNetworkACLRulesOptions{ + NetworkACLID: &nwACLID, + } + if directionIntf, ok := d.GetOk("direction"); ok { + direction := directionIntf.(string) + listNetworkACLRulesOptions.Direction = &direction + } for { - listNetworkACLRulesOptions := &vpcv1.ListNetworkACLRulesOptions{ - NetworkACLID: &nwACLID, - } + if start != "" { listNetworkACLRulesOptions.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_public_gateways.go b/ibm/service/vpc/data_source_ibm_is_public_gateways.go index 0a47a43cda..4294cd7985 100644 --- a/ibm/service/vpc/data_source_ibm_is_public_gateways.go +++ b/ibm/service/vpc/data_source_ibm_is_public_gateways.go @@ -22,6 +22,11 @@ func DataSourceIBMISPublicGateways() *schema.Resource { Read: dataSourceIBMISPublicGatewaysRead, Schema: map[string]*schema.Schema{ + isPublicGatewayResourceGroup: { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this public gateway belongs to", + }, isPublicGateways: { Type: schema.TypeList, Description: "List of public gateways", diff --git a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go index 719768b0b0..4243a134a0 100644 --- a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go +++ b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go @@ -23,6 +23,16 @@ func DataSourceIBMISEndpointGateways() *schema.Resource { Read: dataSourceIBMISEndpointGatewaysRead, Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this endpoint gateway belongs to", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the endpoint gateway group", + }, isVirtualEndpointGateways: { Type: schema.TypeList, Computed: true, @@ -157,8 +167,17 @@ func dataSourceIBMISEndpointGatewaysRead(d *schema.ResourceData, meta interface{ start := "" allrecs := []vpcv1.EndpointGateway{} + options := sess.NewListEndpointGatewaysOptions() + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + options.ResourceGroupID = &resGroup + } + if nameintf, ok := d.GetOk("name"); ok { + name := nameintf.(string) + options.Name = &name + } for { - options := sess.NewListEndpointGatewaysOptions() + if start != "" { options.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go b/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go index 9b35803fdb..b157c50f04 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go +++ b/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go @@ -42,6 +42,11 @@ func DataSourceIBMISVPCRoutingTables() *schema.Resource { Required: true, Description: "VPC identifier", }, + isRoutingTableDefault: { + Type: schema.TypeBool, + Optional: true, + Description: "Filters the collection to routing tables with the specified is_default value", + }, isRoutingTables: { Type: schema.TypeList, Description: "Collection of Routing tables", @@ -169,11 +174,15 @@ func dataSourceIBMISVPCRoutingTablesList(d *schema.ResourceData, meta interface{ } vpcID := d.Get(isVpcID).(string) + listOptions := sess.NewListVPCRoutingTablesOptions(vpcID) + if isDefaultIntf, ok := d.GetOk(isRoutingTableDefault); ok { + isDefault := isDefaultIntf.(bool) + listOptions.IsDefault = &isDefault + } start := "" allrecs := []vpcv1.RoutingTable{} for { - listOptions := sess.NewListVPCRoutingTablesOptions(vpcID) if start != "" { listOptions.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_vpcs.go b/ibm/service/vpc/data_source_ibm_is_vpcs.go index 093618c2aa..226be33774 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpcs.go +++ b/ibm/service/vpc/data_source_ibm_is_vpcs.go @@ -28,6 +28,16 @@ func DataSourceIBMISVPCs() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceIBMISVPCListRead, Schema: map[string]*schema.Schema{ + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this vpc belongs to", + }, + "classic_access": { + Type: schema.TypeBool, + Optional: true, + Description: "Filters the collection to VPCs with the specified classic_access value", + }, isVPCs: { Type: schema.TypeList, Description: "Collection of VPCs", @@ -314,9 +324,17 @@ func dataSourceIBMISVPCListRead(context context.Context, d *schema.ResourceData, } start := "" allrecs := []vpcv1.VPC{} + listOptions := &vpcv1.ListVpcsOptions{} + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + listOptions.ResourceGroupID = &resGroup + } + if classicAccessIntf, ok := d.GetOk("classic_access"); ok { + classicAccess := classicAccessIntf.(bool) + listOptions.ClassicAccess = &classicAccess + } for { - listOptions := &vpcv1.ListVpcsOptions{} if start != "" { listOptions.Start = &start } diff --git a/ibm/service/vpc/data_source_ibm_is_vpn_gateway_connections.go b/ibm/service/vpc/data_source_ibm_is_vpn_gateway_connections.go index b185258331..f073c31951 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpn_gateway_connections.go +++ b/ibm/service/vpc/data_source_ibm_is_vpn_gateway_connections.go @@ -23,7 +23,11 @@ func DataSourceIBMISVPNGatewayConnections() *schema.Resource { Read: dataSourceIBMVPNGatewayConnectionsRead, Schema: map[string]*schema.Schema{ - + "status": { + Type: schema.TypeString, + Optional: true, + Description: "The status of the vpn gateway connection", + }, isVPNGatewayID: { Type: schema.TypeString, Required: true, @@ -161,7 +165,10 @@ func dataSourceIBMVPNGatewayConnectionsRead(d *schema.ResourceData, meta interfa } vpngatewayID := d.Get(isVPNGatewayID).(string) listvpnGWConnectionOptions := sess.NewListVPNGatewayConnectionsOptions(vpngatewayID) - + if statusIntf, ok := d.GetOk("status"); ok { + status := statusIntf.(string) + listvpnGWConnectionOptions.Status = &status + } availableVPNGatewayConnections, detail, err := sess.ListVPNGatewayConnections(listvpnGWConnectionOptions) if err != nil { return fmt.Errorf("[ERROR] Error reading list of VPN Gateway Connections:%s\n%s", err, detail) diff --git a/ibm/service/vpc/data_source_ibm_is_vpn_gateways.go b/ibm/service/vpc/data_source_ibm_is_vpn_gateways.go index d1ca60a92b..5301873f78 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpn_gateways.go +++ b/ibm/service/vpc/data_source_ibm_is_vpn_gateways.go @@ -24,7 +24,16 @@ func DataSourceIBMISVPNGateways() *schema.Resource { Read: dataSourceIBMVPNGatewaysRead, Schema: map[string]*schema.Schema{ - + "resource_group": { + Type: schema.TypeString, + Optional: true, + Description: "The unique identifier of the resource group this vpn gateway belongs to", + }, + "mode": { + Type: schema.TypeString, + Optional: true, + Description: "The mode of this vpn gateway.", + }, isvpnGateways: { Type: schema.TypeList, Description: "Collection of VPN Gateways", @@ -177,7 +186,14 @@ func dataSourceIBMVPNGatewaysRead(d *schema.ResourceData, meta interface{}) erro } listvpnGWOptions := sess.NewListVPNGatewaysOptions() - + if resgroupintf, ok := d.GetOk("resource_group"); ok { + resGroup := resgroupintf.(string) + listvpnGWOptions.ResourceGroupID = &resGroup + } + if modeIntf, ok := d.GetOk("mode"); ok { + mode := modeIntf.(string) + listvpnGWOptions.Mode = &mode + } start := "" allrecs := []vpcv1.VPNGatewayIntf{} for { diff --git a/website/docs/d/is_bare_metal_servers.markdown b/website/docs/d/is_bare_metal_servers.markdown index 2a4e24334f..9347c19864 100644 --- a/website/docs/d/is_bare_metal_servers.markdown +++ b/website/docs/d/is_bare_metal_servers.markdown @@ -28,6 +28,18 @@ data "ibm_is_bare_metal_servers" "example" { } ``` +## Argument reference +Review the argument references that you can specify for your data source. + +- `resource_group` - (Optional, String) The ID of the Resource group this dedicated host group belongs to. +- `vpc` (Optional, String) The vpc ID this bare metal server is in +- `vpc_name` (Optional, String) The name of the vpc this bare metal server is in +- `vpc_crn` (Optional, String) The CRN of the vpc this bare metal server is in +- `name` - (Optional, String) The name of the dedicated host group +- `network_interfaces_subnet` - (Optional, String) The ID of the subnet of the bare metal server network interfaces +- `network_interfaces_subnet_crn` - (Optional, String) The CRN of the subnet of the bare metal server network interfaces +- `network_interfaces_subnet_name` - (Optional, String) The name of the subnet of the bare metal server network interfaces + ## Attribute Reference Review the attribute references that you can access after you retrieve your data source. diff --git a/website/docs/d/is_dedicated_host_groups.html.markdown b/website/docs/d/is_dedicated_host_groups.html.markdown index c4c96d5031..989d79fbd7 100644 --- a/website/docs/d/is_dedicated_host_groups.html.markdown +++ b/website/docs/d/is_dedicated_host_groups.html.markdown @@ -27,6 +27,13 @@ data "ibm_is_dedicated_host_groups" "example" { } ``` +## Argument reference +Review the argument references that you can specify for your data source. + +- `resource_group` - (Optional, String) The ID of the Resource group this dedicated host group belongs to. +- `name` - (Optional, String) The name of the dedicated host group +- `zone` - (Optional, String) The name of the zone this dedicated host group is in + ## Attribute reference In addition to all argument reference list, you can access the following attribute references after your data source is created. diff --git a/website/docs/d/is_dedicated_hosts.html.markdown b/website/docs/d/is_dedicated_hosts.html.markdown index ce0839fe6c..cb9799db67 100644 --- a/website/docs/d/is_dedicated_hosts.html.markdown +++ b/website/docs/d/is_dedicated_hosts.html.markdown @@ -32,7 +32,8 @@ data "ibm_is_dedicated_hosts" "example" { Review the argument references that you can specify for your data source. - `host_group` - (Optional, String) The unique identifier of the dedicated host group. - +- `resource_group` (Optional, String) The ID of the Resource group this dedicated host belongs to. +- `name` (Optional, String) The name of the dedicated host ## Attribute reference In addition to all argument reference list, you can access the following attribute references after your data source is created. diff --git a/website/docs/d/is_floating_ips.html.markdown b/website/docs/d/is_floating_ips.html.markdown index 4383a1a8a1..293c557f34 100644 --- a/website/docs/d/is_floating_ips.html.markdown +++ b/website/docs/d/is_floating_ips.html.markdown @@ -34,6 +34,7 @@ data "ibm_is_floating_ips" "example" { Review the argument reference that you can specify for your data source. - `name` - (Optional, String) The unique user-defined name for this floating IP. +- `resource_group` - (String) The ID of the Resource group this floating ips belongs to. ## Attribute reference diff --git a/website/docs/d/is_flow_logs.html.markdown b/website/docs/d/is_flow_logs.html.markdown index 66607953f9..c0f1040358 100644 --- a/website/docs/d/is_flow_logs.html.markdown +++ b/website/docs/d/is_flow_logs.html.markdown @@ -28,8 +28,28 @@ provider "ibm" { data "ibm_is_flow_logs" "example" { } +data "ibm_is_flow_logs" "example1" { + name = "my-flow-log" + vpc_name = ibm_is_vpc.example.name + vpc_crn = ibm_is_vpc.example.crn + vpc = ibm_is_vpc.example.id + resource_group = ibm_is_vpc.example.resource_group + target = ibm_is_vpc.example.id + target_resource_type = "vpc" +} ``` +## Argument reference + +Review the argument references that you can specify for your data source. +- `name` - (String) The name of the flow log collector +- `vpc_name` - (String) The name of the VPC this flow log collector resides in +- `vpc_crn` - (String) The CRN of the VPC this flow log collector resides in +- `vpc` - (String) The ID of the VPC this flow log collector resides in +- `resource_group` - (String) The ID of the Resource group this flow log collector belongs to +- `target` - (String) The ID of the target this collector is collecting flow logs for. +- `target_resource_type` - (String) The target resource type for this flow log collector. Available options are `instance`, `network_interface`, `subnet`, `vpc` + ## Attribute reference Review the attribute references that you can access after you retrieve your data source. diff --git a/website/docs/d/is_network_acl_rules.html.markdown b/website/docs/d/is_network_acl_rules.html.markdown index 4d5672afd6..1a2ebe6fcd 100644 --- a/website/docs/d/is_network_acl_rules.html.markdown +++ b/website/docs/d/is_network_acl_rules.html.markdown @@ -34,7 +34,7 @@ data "ibm_is_network_acl_rules" "example"{ Review the argument references that you can specify for your resource. - `network_acl` - (Required, String) The network ACL identifier. - +- `direction` - (Optional, String) The direction of the rules to filter. Available options are `inbound` and `outbound` ## Attribute reference diff --git a/website/docs/d/is_public_gateways.html.markdown b/website/docs/d/is_public_gateways.html.markdown index ad537331cb..ce45c6e5e2 100644 --- a/website/docs/d/is_public_gateways.html.markdown +++ b/website/docs/d/is_public_gateways.html.markdown @@ -28,6 +28,12 @@ data "ibm_is_public_gateways" "example"{ ``` +## Argument reference + +Review the argument references that you can specify for your data source. + +- `resource_group` - (String) The ID of the Resource group this public gateway belongs to. + ## Attribute reference Review the attribute references that you can access after you retrieve your data source. diff --git a/website/docs/d/is_virtual_endpoint_gateways.html.markdown b/website/docs/d/is_virtual_endpoint_gateways.html.markdown index 5470496293..e874e23053 100644 --- a/website/docs/d/is_virtual_endpoint_gateways.html.markdown +++ b/website/docs/d/is_virtual_endpoint_gateways.html.markdown @@ -27,6 +27,13 @@ data "ibm_is_virtual_endpoint_gateways" "example" { } ``` +## Argument reference + +Review the argument references that you can specify for your data source. + +- `resource_group` - (String) The ID of the Resource group this endpoint gateway belongs to +- `name` - (String) The name of the endpoint gateway + ## Attribute reference In addition to the argument reference list, you can access the following attribute references after your data source is created. diff --git a/website/docs/d/is_vpc_routing_tables.html.markdown b/website/docs/d/is_vpc_routing_tables.html.markdown index c57fd90d54..b38983b1be 100644 --- a/website/docs/d/is_vpc_routing_tables.html.markdown +++ b/website/docs/d/is_vpc_routing_tables.html.markdown @@ -37,6 +37,7 @@ data "ibm_is_vpc_routing_tables" "example" { Review the argument references that you can specify for your data source. - `vpc` - (Required, String) The ID of the VPC. +- `is_default` - (Optional, Boolean) Indicate whether this is the default routing table for this VPC ## Attribute reference In addition to the argument reference list, you can access the following attribute references after your data source is created. diff --git a/website/docs/d/is_vpcs.html.markdown b/website/docs/d/is_vpcs.html.markdown index 21940bf14c..99f2870e6f 100644 --- a/website/docs/d/is_vpcs.html.markdown +++ b/website/docs/d/is_vpcs.html.markdown @@ -31,6 +31,12 @@ data "ibm_is_vpcs" "example" { } ``` +## Argument reference + +Review the argument references that you can specify for your data source. + +- `resource_group` - (Optional, String) The ID of the Resource group this flow log collector belongs to +- `classic_access` - (Optional, Boolean) Indicates whether this VPC is connected to Classic Infrastructure. ## Attribute reference You can access the following attribute references after your data source is created. diff --git a/website/docs/d/is_vpn_gateways.html.markdown b/website/docs/d/is_vpn_gateways.html.markdown index 364a75ba9e..81e9a34fae 100644 --- a/website/docs/d/is_vpn_gateways.html.markdown +++ b/website/docs/d/is_vpn_gateways.html.markdown @@ -28,6 +28,12 @@ data "ibm_is_vpn_gateways" "example" { } ``` +## Argument reference + +Review the argument references that you can specify for your data source. + +- `resource_group` - (Optional, String) The ID of the Resource group this vpn gateway belongs to +- `mode` - (Optional, String) The mode of this VPN Gateway. Available options are `policy` and `route`. ## Attribute reference In addition to all argument reference list, you can access the following attribute references after your data source is created.