# PCAPs ## List packet capture requests `client.MagicTransit.PCAPs.List(ctx, query) (*SinglePage[PCAPListResponse], error)` **get** `/accounts/{account_id}/pcaps` Lists all packet capture requests for an account. ### Parameters - `query PCAPListParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type PCAPListResponse interface{…}` - `type PCAP struct{…}` - `ID string` The ID for the packet capture. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `DestinationAddress string` The destination IP address of the packet. - `DestinationPort float64` The destination port of the packet. - `Protocol float64` The protocol number of the packet. - `SourceAddress string` The source IP address of the packet. - `SourcePort float64` The source port of the packet. - `OffsetTime Time` The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request. - `Status PCAPStatus` The status of the packet capture request. - `const PCAPStatusUnknown PCAPStatus = "unknown"` - `const PCAPStatusSuccess PCAPStatus = "success"` - `const PCAPStatusPending PCAPStatus = "pending"` - `const PCAPStatusRunning PCAPStatus = "running"` - `const PCAPStatusConversionPending PCAPStatus = "conversion_pending"` - `const PCAPStatusConversionRunning PCAPStatus = "conversion_running"` - `const PCAPStatusComplete PCAPStatus = "complete"` - `const PCAPStatusFailed PCAPStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPSystem` The system used to collect packet captures. - `const PCAPSystemMagicTransit PCAPSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPTypeSimple PCAPType = "simple"` - `const PCAPTypeFull PCAPType = "full"` - `type PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFull struct{…}` - `ID string` The ID for the packet capture. - `ByteLimit float64` The maximum number of bytes to capture. This field only applies to `full` packet captures. - `ColoName string` The name of the data center used for the packet capture. This can be a specific colo (ord02) or a multi-colo name (ORD). This field only applies to `full` packet captures. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `ErrorMessage string` An error message that describes why the packet capture failed. This field only applies to `full` packet captures. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `PacketsCaptured int64` The number of packets captured. - `Status PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus` The status of the packet capture request. - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusUnknown PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "unknown"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusSuccess PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "success"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusPending PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "pending"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusRunning PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "running"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionPending PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_pending"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionRunning PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_running"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusComplete PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "complete"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatusFailed PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "failed"` - `StopRequested Time` The RFC 3339 timestamp when stopping the packet capture was requested. This field only applies to `full` packet captures. - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullSystem` The system used to collect packet captures. - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullSystemMagicTransit PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullTypeSimple PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullType = "simple"` - `const PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullTypeFull PCAPListResponseMagicVisibilityPCAPsPCAPsResponseFullType = "full"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.MagicTransit.PCAPs.List(context.TODO(), magic_transit.PCAPListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "66802ca5668e47a2b82c2e6746e45037", "filter_v1": { "destination_address": "1.2.3.4", "destination_port": 80, "protocol": 6, "source_address": "1.2.3.4", "source_port": 123 }, "offset_time": "2020-01-01T08:00:00Z", "status": "success", "submitted": "2020-01-01T08:00:00Z", "system": "magic-transit", "time_limit": 300, "type": "simple" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get PCAP request `client.MagicTransit.PCAPs.Get(ctx, pcapID, query) (*PCAPGetResponse, error)` **get** `/accounts/{account_id}/pcaps/{pcap_id}` Get information for a PCAP request by id. ### Parameters - `pcapID string` Identifier. - `query PCAPGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type PCAPGetResponse interface{…}` - `type PCAP struct{…}` - `ID string` The ID for the packet capture. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `DestinationAddress string` The destination IP address of the packet. - `DestinationPort float64` The destination port of the packet. - `Protocol float64` The protocol number of the packet. - `SourceAddress string` The source IP address of the packet. - `SourcePort float64` The source port of the packet. - `OffsetTime Time` The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request. - `Status PCAPStatus` The status of the packet capture request. - `const PCAPStatusUnknown PCAPStatus = "unknown"` - `const PCAPStatusSuccess PCAPStatus = "success"` - `const PCAPStatusPending PCAPStatus = "pending"` - `const PCAPStatusRunning PCAPStatus = "running"` - `const PCAPStatusConversionPending PCAPStatus = "conversion_pending"` - `const PCAPStatusConversionRunning PCAPStatus = "conversion_running"` - `const PCAPStatusComplete PCAPStatus = "complete"` - `const PCAPStatusFailed PCAPStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPSystem` The system used to collect packet captures. - `const PCAPSystemMagicTransit PCAPSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPTypeSimple PCAPType = "simple"` - `const PCAPTypeFull PCAPType = "full"` - `type PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFull struct{…}` - `ID string` The ID for the packet capture. - `ByteLimit float64` The maximum number of bytes to capture. This field only applies to `full` packet captures. - `ColoName string` The name of the data center used for the packet capture. This can be a specific colo (ord02) or a multi-colo name (ORD). This field only applies to `full` packet captures. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `ErrorMessage string` An error message that describes why the packet capture failed. This field only applies to `full` packet captures. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `PacketsCaptured int64` The number of packets captured. - `Status PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus` The status of the packet capture request. - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusUnknown PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "unknown"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusSuccess PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "success"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusPending PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "pending"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusRunning PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "running"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionPending PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_pending"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionRunning PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_running"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusComplete PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "complete"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatusFailed PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "failed"` - `StopRequested Time` The RFC 3339 timestamp when stopping the packet capture was requested. This field only applies to `full` packet captures. - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullSystem` The system used to collect packet captures. - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullSystemMagicTransit PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullTypeSimple PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullType = "simple"` - `const PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullTypeFull PCAPGetResponseMagicVisibilityPCAPsPCAPsResponseFullType = "full"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pcap, err := client.MagicTransit.PCAPs.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.PCAPGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pcap) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "66802ca5668e47a2b82c2e6746e45037", "filter_v1": { "destination_address": "1.2.3.4", "destination_port": 80, "protocol": 6, "source_address": "1.2.3.4", "source_port": 123 }, "offset_time": "2020-01-01T08:00:00Z", "status": "success", "submitted": "2020-01-01T08:00:00Z", "system": "magic-transit", "time_limit": 300, "type": "simple" }, "success": true } ``` ## Create PCAP request `client.MagicTransit.PCAPs.New(ctx, params) (*PCAPNewResponse, error)` **post** `/accounts/{account_id}/pcaps` Create new PCAP request for account. ### Parameters - `params PCAPNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `PacketLimit param.Field[float64]` Body param: The limit of packets contained in a packet capture. - `System param.Field[PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleSystem]` Body param: The system used to collect packet captures. - `const PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleSystemMagicTransit PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleSystem = "magic-transit"` - `TimeLimit param.Field[float64]` Body param: The packet capture duration in seconds. - `Type param.Field[PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleType]` Body param: The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleTypeSimple PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleType = "simple"` - `const PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleTypeFull PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleType = "full"` - `FilterV1 param.Field[PCAPFilter]` Body param: The packet capture filter. When this field is empty, all packets are captured. - `OffsetTime param.Field[Time]` Body param: The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request. ### Returns - `type PCAPNewResponse interface{…}` - `type PCAP struct{…}` - `ID string` The ID for the packet capture. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `DestinationAddress string` The destination IP address of the packet. - `DestinationPort float64` The destination port of the packet. - `Protocol float64` The protocol number of the packet. - `SourceAddress string` The source IP address of the packet. - `SourcePort float64` The source port of the packet. - `OffsetTime Time` The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request. - `Status PCAPStatus` The status of the packet capture request. - `const PCAPStatusUnknown PCAPStatus = "unknown"` - `const PCAPStatusSuccess PCAPStatus = "success"` - `const PCAPStatusPending PCAPStatus = "pending"` - `const PCAPStatusRunning PCAPStatus = "running"` - `const PCAPStatusConversionPending PCAPStatus = "conversion_pending"` - `const PCAPStatusConversionRunning PCAPStatus = "conversion_running"` - `const PCAPStatusComplete PCAPStatus = "complete"` - `const PCAPStatusFailed PCAPStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPSystem` The system used to collect packet captures. - `const PCAPSystemMagicTransit PCAPSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPTypeSimple PCAPType = "simple"` - `const PCAPTypeFull PCAPType = "full"` - `type PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFull struct{…}` - `ID string` The ID for the packet capture. - `ByteLimit float64` The maximum number of bytes to capture. This field only applies to `full` packet captures. - `ColoName string` The name of the data center used for the packet capture. This can be a specific colo (ord02) or a multi-colo name (ORD). This field only applies to `full` packet captures. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `ErrorMessage string` An error message that describes why the packet capture failed. This field only applies to `full` packet captures. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `PacketsCaptured int64` The number of packets captured. - `Status PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus` The status of the packet capture request. - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusUnknown PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "unknown"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusSuccess PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "success"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusPending PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "pending"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusRunning PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "running"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionPending PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_pending"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionRunning PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_running"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusComplete PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "complete"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusFailed PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "failed"` - `StopRequested Time` The RFC 3339 timestamp when stopping the packet capture was requested. This field only applies to `full` packet captures. - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullSystem` The system used to collect packet captures. - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullSystemMagicTransit PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullTypeSimple PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullType = "simple"` - `const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullTypeFull PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullType = "full"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pcap, err := client.MagicTransit.PCAPs.New(context.TODO(), magic_transit.PCAPNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: magic_transit.PCAPNewParamsBodyMagicVisibilityPCAPsPCAPsRequestSimple{ PacketLimit: cloudflare.F(10000.000000), System: cloudflare.F(magic_transit.PCAPNewParamsBodyMagicVisibilityPCAPsPCAPsRequestSimpleSystemMagicTransit), TimeLimit: cloudflare.F(300.000000), Type: cloudflare.F(magic_transit.PCAPNewParamsBodyMagicVisibilityPCAPsPCAPsRequestSimpleTypeSimple), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pcap) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "66802ca5668e47a2b82c2e6746e45037", "filter_v1": { "destination_address": "1.2.3.4", "destination_port": 80, "protocol": 6, "source_address": "1.2.3.4", "source_port": 123 }, "offset_time": "2020-01-01T08:00:00Z", "status": "success", "submitted": "2020-01-01T08:00:00Z", "system": "magic-transit", "time_limit": 300, "type": "simple" }, "success": true } ``` ## Stop full PCAP `client.MagicTransit.PCAPs.Stop(ctx, pcapID, body) error` **put** `/accounts/{account_id}/pcaps/{pcap_id}/stop` Stop full PCAP. ### Parameters - `pcapID string` Identifier. - `body PCAPStopParams` - `AccountID param.Field[string]` Identifier. ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) err := client.MagicTransit.PCAPs.Stop( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.PCAPStopParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } } ``` ## Domain Types ### PCAP - `type PCAP struct{…}` - `ID string` The ID for the packet capture. - `FilterV1 PCAPFilter` The packet capture filter. When this field is empty, all packets are captured. - `DestinationAddress string` The destination IP address of the packet. - `DestinationPort float64` The destination port of the packet. - `Protocol float64` The protocol number of the packet. - `SourceAddress string` The source IP address of the packet. - `SourcePort float64` The source port of the packet. - `OffsetTime Time` The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request. - `Status PCAPStatus` The status of the packet capture request. - `const PCAPStatusUnknown PCAPStatus = "unknown"` - `const PCAPStatusSuccess PCAPStatus = "success"` - `const PCAPStatusPending PCAPStatus = "pending"` - `const PCAPStatusRunning PCAPStatus = "running"` - `const PCAPStatusConversionPending PCAPStatus = "conversion_pending"` - `const PCAPStatusConversionRunning PCAPStatus = "conversion_running"` - `const PCAPStatusComplete PCAPStatus = "complete"` - `const PCAPStatusFailed PCAPStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the packet capture was created. - `System PCAPSystem` The system used to collect packet captures. - `const PCAPSystemMagicTransit PCAPSystem = "magic-transit"` - `TimeLimit float64` The packet capture duration in seconds. - `Type PCAPType` The type of packet capture. `Simple` captures sampled packets, and `full` captures entire payloads and non-sampled packets. - `const PCAPTypeSimple PCAPType = "simple"` - `const PCAPTypeFull PCAPType = "full"` ### PCAP Filter - `type PCAPFilter struct{…}` The packet capture filter. When this field is empty, all packets are captured. - `DestinationAddress string` The destination IP address of the packet. - `DestinationPort float64` The destination port of the packet. - `Protocol float64` The protocol number of the packet. - `SourceAddress string` The source IP address of the packet. - `SourcePort float64` The source port of the packet. # Ownership ## List PCAPs Bucket Ownership `client.MagicTransit.PCAPs.Ownership.Get(ctx, query) (*SinglePage[Ownership], error)` **get** `/accounts/{account_id}/pcaps/ownership` List all buckets configured for use with PCAPs API. ### Parameters - `query PCAPOwnershipGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type Ownership struct{…}` - `ID string` The bucket ID associated with the packet captures API. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `Filename string` The ownership challenge filename stored in the bucket. - `Status OwnershipStatus` The status of the ownership challenge. Can be pending, success or failed. - `const OwnershipStatusPending OwnershipStatus = "pending"` - `const OwnershipStatusSuccess OwnershipStatus = "success"` - `const OwnershipStatusFailed OwnershipStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the bucket was added to packet captures API. - `Validated string` The RFC 3339 timestamp when the bucket was validated. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.MagicTransit.PCAPs.Ownership.Get(context.TODO(), magic_transit.PCAPOwnershipGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "9883874ecac311ec8475433579a6bf5f", "destination_conf": "s3://pcaps-bucket?region=us-east-1", "filename": "ownership-challenge-9883874ecac311ec8475433579a6bf5f.txt", "status": "success", "submitted": "2020-01-01T08:00:00Z", "validated": "2020-01-01T08:00:00Z" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Add buckets for full packet captures `client.MagicTransit.PCAPs.Ownership.New(ctx, params) (*Ownership, error)` **post** `/accounts/{account_id}/pcaps/ownership` Adds an AWS or GCP bucket to use with full packet captures. ### Parameters - `params PCAPOwnershipNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `DestinationConf param.Field[string]` Body param: The full URI for the bucket. This field only applies to `full` packet captures. ### Returns - `type Ownership struct{…}` - `ID string` The bucket ID associated with the packet captures API. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `Filename string` The ownership challenge filename stored in the bucket. - `Status OwnershipStatus` The status of the ownership challenge. Can be pending, success or failed. - `const OwnershipStatusPending OwnershipStatus = "pending"` - `const OwnershipStatusSuccess OwnershipStatus = "success"` - `const OwnershipStatusFailed OwnershipStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the bucket was added to packet captures API. - `Validated string` The RFC 3339 timestamp when the bucket was validated. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) ownership, err := client.MagicTransit.PCAPs.Ownership.New(context.TODO(), magic_transit.PCAPOwnershipNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-1"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", ownership.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "9883874ecac311ec8475433579a6bf5f", "destination_conf": "s3://pcaps-bucket?region=us-east-1", "filename": "ownership-challenge-9883874ecac311ec8475433579a6bf5f.txt", "status": "success", "submitted": "2020-01-01T08:00:00Z", "validated": "2020-01-01T08:00:00Z" }, "success": true } ``` ## Delete buckets for full packet captures `client.MagicTransit.PCAPs.Ownership.Delete(ctx, ownershipID, body) error` **delete** `/accounts/{account_id}/pcaps/ownership/{ownership_id}` Deletes buckets added to the packet captures API. ### Parameters - `ownershipID string` Identifier. - `body PCAPOwnershipDeleteParams` - `AccountID param.Field[string]` Identifier. ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) err := client.MagicTransit.PCAPs.Ownership.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.PCAPOwnershipDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } } ``` ## Validate buckets for full packet captures `client.MagicTransit.PCAPs.Ownership.Validate(ctx, params) (*Ownership, error)` **post** `/accounts/{account_id}/pcaps/ownership/validate` Validates buckets added to the packet captures API. ### Parameters - `params PCAPOwnershipValidateParams` - `AccountID param.Field[string]` Path param: Identifier. - `DestinationConf param.Field[string]` Body param: The full URI for the bucket. This field only applies to `full` packet captures. - `OwnershipChallenge param.Field[string]` Body param: The ownership challenge filename stored in the bucket. ### Returns - `type Ownership struct{…}` - `ID string` The bucket ID associated with the packet captures API. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `Filename string` The ownership challenge filename stored in the bucket. - `Status OwnershipStatus` The status of the ownership challenge. Can be pending, success or failed. - `const OwnershipStatusPending OwnershipStatus = "pending"` - `const OwnershipStatusSuccess OwnershipStatus = "success"` - `const OwnershipStatusFailed OwnershipStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the bucket was added to packet captures API. - `Validated string` The RFC 3339 timestamp when the bucket was validated. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) ownership, err := client.MagicTransit.PCAPs.Ownership.Validate(context.TODO(), magic_transit.PCAPOwnershipValidateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-1"), OwnershipChallenge: cloudflare.F("ownership-challenge-9883874ecac311ec8475433579a6bf5f.txt"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", ownership.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "9883874ecac311ec8475433579a6bf5f", "destination_conf": "s3://pcaps-bucket?region=us-east-1", "filename": "ownership-challenge-9883874ecac311ec8475433579a6bf5f.txt", "status": "success", "submitted": "2020-01-01T08:00:00Z", "validated": "2020-01-01T08:00:00Z" }, "success": true } ``` ## Domain Types ### Ownership - `type Ownership struct{…}` - `ID string` The bucket ID associated with the packet captures API. - `DestinationConf string` The full URI for the bucket. This field only applies to `full` packet captures. - `Filename string` The ownership challenge filename stored in the bucket. - `Status OwnershipStatus` The status of the ownership challenge. Can be pending, success or failed. - `const OwnershipStatusPending OwnershipStatus = "pending"` - `const OwnershipStatusSuccess OwnershipStatus = "success"` - `const OwnershipStatusFailed OwnershipStatus = "failed"` - `Submitted string` The RFC 3339 timestamp when the bucket was added to packet captures API. - `Validated string` The RFC 3339 timestamp when the bucket was validated. # Download ## Download Simple PCAP `client.MagicTransit.PCAPs.Download.Get(ctx, pcapID, query) (*Response, error)` **get** `/accounts/{account_id}/pcaps/{pcap_id}/download` Download PCAP information into a file. Response is a binary PCAP file. ### Parameters - `pcapID string` Identifier. - `query PCAPDownloadGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type PCAPDownloadGetResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) download, err := client.MagicTransit.PCAPs.Download.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.PCAPDownloadGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", download) } ```