Skip to content

Latest commit

 

History

History
140 lines (103 loc) · 5.77 KB

README.md

File metadata and controls

140 lines (103 loc) · 5.77 KB

Logs

(Logs)

Overview

Available Operations

SearchLogs

Search logs within a time period

Example Usage

package main

import(
	"os"
	swosdkgo "github.com/solarwinds/swo-sdk-go"
	"github.com/solarwinds/swo-sdk-go/models/operations"
	"context"
	"log"
)

func main() {
    s := swosdkgo.New(
        swosdkgo.WithSecurity(os.Getenv("SWO_API_TOKEN")),
    )

    ctx := context.Background()
    res, err := s.Logs.SearchLogs(ctx, operations.SearchLogsRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
                for {
            // handle items
        
            res, err = res.Next()
        
            if err != nil {
                // handle error
            }
        
            if res == nil {
                break
            }
        }
        
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.SearchLogsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SearchLogsResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

ListLogArchives

Retrieves a list of log archives within a time period.

Example Usage

package main

import(
	"os"
	swosdkgo "github.com/solarwinds/swo-sdk-go"
	"github.com/solarwinds/swo-sdk-go/models/operations"
	"context"
	"log"
)

func main() {
    s := swosdkgo.New(
        swosdkgo.WithSecurity(os.Getenv("SWO_API_TOKEN")),
    )

    ctx := context.Background()
    res, err := s.Logs.ListLogArchives(ctx, operations.ListLogArchivesRequest{
        StartTime: "<value>",
        EndTime: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
                for {
            // handle items
        
            res, err = res.Next()
        
            if err != nil {
                // handle error
            }
        
            if res == nil {
                break
            }
        }
        
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.ListLogArchivesRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListLogArchivesResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*