Skip to content

Commit

Permalink
examples: Migrate to V2 Host Details API
Browse files Browse the repository at this point in the history
A new v2 version of the Get host details endpoint is now available. This new
version replaces the previous GET /devices/entities/devices/v1 endpoint with two
request options that support Falcon Flight Control and improve the way large
requests are handled.

Original V1 GetDeviceDetails is deprecated. Please use new devices v2 endpoints.
V1 endpoint will be removed on or sometime after february 9 2023.
  • Loading branch information
isimluk committed Aug 11, 2022
1 parent 9f69588 commit beaeee5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions examples/falcon_cleanup_hosts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Falcon Client Secret`)
}
}

func visualizeHost(host *models.DomainDeviceSwagger) {
func visualizeHost(host *models.DeviceapiDeviceSwagger) {
cloud := "NoCloud"
if host.ServiceProvider != "" {
cloud = host.ServiceProvider
Expand Down Expand Up @@ -156,15 +156,15 @@ func visualizeHost(host *models.DomainDeviceSwagger) {
fmt.Printf("%s - %s %s %s (%s) (life_span=%s) (%s) \n", *host.DeviceID, cloud, platform, typ, name, lifeSpan, active)
}

func debug(host *models.DomainDeviceSwagger) {
func debug(host *models.DeviceapiDeviceSwagger) {
json, err := falcon_util.PrettyJson(host)
if err != nil {
panic(err)
}
fmt.Println(json)
}

func hideHosts(client *client.CrowdStrikeAPISpecification, hosts []*models.DomainDeviceSwagger, dryRun bool, limit int) error {
func hideHosts(client *client.CrowdStrikeAPISpecification, hosts []*models.DeviceapiDeviceSwagger, dryRun bool, limit int) error {
dryRunString := ""
if dryRun {
dryRunString = "(DRY-RUN) "
Expand All @@ -185,7 +185,7 @@ func hideHosts(client *client.CrowdStrikeAPISpecification, hosts []*models.Domai
return nil
}

func hideHostsInternal(client *client.CrowdStrikeAPISpecification, hostList []*models.DomainDeviceSwagger) error {
func hideHostsInternal(client *client.CrowdStrikeAPISpecification, hostList []*models.DeviceapiDeviceSwagger) error {
hostIds := []string{}
for _, host := range hostList {
hostIds = append(hostIds, *host.DeviceID)
Expand All @@ -205,8 +205,8 @@ func hideHostsInternal(client *client.CrowdStrikeAPISpecification, hostList []*m
return falcon.AssertNoError(response.Payload.Errors)
}

func getAllHostDetails(client *client.CrowdStrikeAPISpecification, filter *string) []*models.DomainDeviceSwagger {
result := []*models.DomainDeviceSwagger{}
func getAllHostDetails(client *client.CrowdStrikeAPISpecification, filter *string) []*models.DeviceapiDeviceSwagger {
result := []*models.DeviceapiDeviceSwagger{}

for hostIdBatch := range getHostIds(client, filter) {
if len(hostIdBatch) == 0 {
Expand All @@ -218,8 +218,8 @@ func getAllHostDetails(client *client.CrowdStrikeAPISpecification, filter *strin
return result
}

func getHostsDetails(client *client.CrowdStrikeAPISpecification, hostIds []string) []*models.DomainDeviceSwagger {
response, err := client.Hosts.GetDeviceDetails(&hosts.GetDeviceDetailsParams{
func getHostsDetails(client *client.CrowdStrikeAPISpecification, hostIds []string) []*models.DeviceapiDeviceSwagger {
response, err := client.Hosts.GetDeviceDetailsV2(&hosts.GetDeviceDetailsV2Params{
Ids: hostIds,
Context: context.Background(),
})
Expand Down Expand Up @@ -264,7 +264,7 @@ func getHostIds(client *client.CrowdStrikeAPISpecification, filter *string) <-ch
return hostIds
}

func chunkBy(items []*models.DomainDeviceSwagger, chunkSize int) (chunks [][]*models.DomainDeviceSwagger) {
func chunkBy(items []*models.DeviceapiDeviceSwagger, chunkSize int) (chunks [][]*models.DeviceapiDeviceSwagger) {
for chunkSize < len(items) {
items, chunks = items[chunkSize:], append(chunks, items[0:chunkSize:chunkSize])
}
Expand Down
4 changes: 2 additions & 2 deletions examples/falcon_cleanup_pods/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func hideHost(client *client.CrowdStrikeAPISpecification, id string) error {
return falcon.AssertNoError(response.Payload.Errors)
}

func getHostDetails(client *client.CrowdStrikeAPISpecification, hostId string) *models.DomainDeviceSwagger {
response, err := client.Hosts.GetDeviceDetails(&hosts.GetDeviceDetailsParams{
func getHostDetails(client *client.CrowdStrikeAPISpecification, hostId string) *models.DeviceapiDeviceSwagger {
response, err := client.Hosts.GetDeviceDetailsV2(&hosts.GetDeviceDetailsV2Params{
Ids: []string{hostId},
Context: context.Background(),
})
Expand Down
4 changes: 2 additions & 2 deletions examples/falcon_host_details/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Falcon Client Secret`)
fmt.Println("]")
}

func getHostsDetails(client *client.CrowdStrikeAPISpecification, hostIds []string) []*models.DomainDeviceSwagger {
response, err := client.Hosts.GetDeviceDetails(&hosts.GetDeviceDetailsParams{
func getHostsDetails(client *client.CrowdStrikeAPISpecification, hostIds []string) []*models.DeviceapiDeviceSwagger {
response, err := client.Hosts.GetDeviceDetailsV2(&hosts.GetDeviceDetailsV2Params{
Ids: hostIds,
Context: context.Background(),
})
Expand Down

0 comments on commit beaeee5

Please sign in to comment.