Skip to content

Commit 0931bab

Browse files
Add Go docs (#44)
* Add Go docs * address comments * Add Go datasets api reference * Add Go workflows api reference * Add Go snippets for Workflows * Add Go snippets for datasets * add spatio-temporal * lint * Address comments
1 parent 4cd802e commit 0931bab

File tree

97 files changed

+4170
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4170
-274
lines changed

.vale.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ StylesPath = "vale/styles"
22

33
Vocab = docs
44
Packages = Google
5-
IgnoredScopes = code, tt, img, url, a
5+
IgnoredScopes = code, tt, img, url, a, text.frontmatter
66
SkippedScopes = script, style, pre, figure, code
77
MinAlertLevel = warning
88

99
# Treat MDX as Markdown
1010
[formats]
1111
mdx = md
1212

13-
[*.{md, mdx}]
13+
[*.{md,mdx}]
1414

1515
# Ignore react components starting with export const
1616
# Ignore code blocks in triple backticks

api-reference/go/datasets/As.mdx

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: As
3+
sidebarTitle: As
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func As[T proto.Message](seq iter.Seq2[[]byte, error]) iter.Seq2[T, error]
9+
```
10+
11+
Convert a sequence of bytes into a sequence of `proto.Message`.
12+
13+
Useful to convert the output of [`Datapoints.Query`](/api-reference/go/datasets/Datapoints.Query) into a sequence of `proto.Message`.
14+
15+
## Parameters
16+
17+
<ParamField path="seq" type="iter.Seq2[[]byte, error]">
18+
The sequence of bytes to convert
19+
</ParamField>
20+
21+
## Returns
22+
23+
A sequence of `proto.Message` or an error if any.
24+
25+
<RequestExample>
26+
```go Go
27+
import (
28+
"time"
29+
datasets "github.com/tilebox/tilebox-go/datasets/v1"
30+
"github.com/tilebox/tilebox-go/query"
31+
)
32+
33+
startDate := time.Date(2014, 10, 4, 0, 0, 0, 0, time.UTC)
34+
endDate := time.Date(2021, 2, 24, 0, 0, 0, 0, time.UTC)
35+
queryInterval := query.NewTimeInterval(startDate, endDate)
36+
37+
seq := datasets.As[*v1.Sentinel1Sar](
38+
client.Datapoints.Query(ctx, collectionID, datasets.WithTemporalExtent(queryInterval)),
39+
)
40+
```
41+
</RequestExample>

api-reference/go/datasets/Collect.mdx

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Collect
3+
sidebarTitle: Collect
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func Collect[K any](seq iter.Seq2[K, error]) ([]K, error)
9+
```
10+
11+
Convert any sequence into a slice.
12+
13+
It return an error if any of the elements in the sequence has a non-nil error.
14+
15+
## Parameters
16+
17+
<ParamField path="seq" type="iter.Seq2[[]K, error]">
18+
The sequence of bytes to convert
19+
</ParamField>
20+
21+
## Returns
22+
23+
A slice of `K` or an error if any.
24+
25+
<RequestExample>
26+
```go Go
27+
import (
28+
"time"
29+
datasets "github.com/tilebox/tilebox-go/datasets/v1"
30+
"github.com/tilebox/tilebox-go/query"
31+
)
32+
33+
startDate := time.Date(2014, 10, 4, 0, 0, 0, 0, time.UTC)
34+
endDate := time.Date(2021, 2, 24, 0, 0, 0, 0, time.UTC)
35+
queryInterval := query.NewTimeInterval(startDate, endDate)
36+
37+
datapoints, err := datasets.Collect(datasets.As[*v1.Sentinel1Sar](
38+
client.Datapoints.Query(ctx, collectionID, datasets.WithTemporalExtent(queryInterval)),
39+
))
40+
```
41+
</RequestExample>
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: CollectAs
3+
sidebarTitle: CollectAs
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func CollectAs[T proto.Message](seq iter.Seq2[[]byte, error]) ([]T, error)
9+
```
10+
11+
Convert a sequence of bytes into a slice of `proto.Message`.
12+
13+
Useful to convert the output of [`Datapoints.Query`](/api-reference/go/datasets/Datapoints.Query) into a slice of `proto.Message`.
14+
15+
This a convenience function for `Collect(As[T](seq))`.
16+
17+
## Parameters
18+
19+
<ParamField path="seq" type="iter.Seq2[[]byte, error]">
20+
The sequence of bytes to convert
21+
</ParamField>
22+
23+
## Returns
24+
25+
A slice of `proto.Message` or an error if any.
26+
27+
<RequestExample>
28+
```go Go
29+
import (
30+
"time"
31+
datasets "github.com/tilebox/tilebox-go/datasets/v1"
32+
"github.com/tilebox/tilebox-go/query"
33+
)
34+
35+
startDate := time.Date(2014, 10, 4, 0, 0, 0, 0, time.UTC)
36+
endDate := time.Date(2021, 2, 24, 0, 0, 0, 0, time.UTC)
37+
queryInterval := query.NewTimeInterval(startDate, endDate)
38+
39+
datapoints, err := datasets.CollectAs[*v1.Sentinel1Sar](
40+
client.Datapoints.Query(ctx, collectionID, datasets.WithTemporalExtent(queryInterval)),
41+
)
42+
```
43+
</RequestExample>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Client.Collections.Create
3+
sidebarTitle: Collections.Create
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func (collectionClient) Create(
9+
ctx context.Context,
10+
datasetID uuid.UUID,
11+
collectionName string,
12+
) (*datasets.Collection, error)
13+
```
14+
15+
Create a collection in the dataset.
16+
17+
## Parameters
18+
19+
<ParamField path="datasetID" type="uuid.UUID">
20+
The id of the dataset
21+
</ParamField>
22+
<ParamField path="collectionName" type="string">
23+
The name of the collection
24+
</ParamField>
25+
26+
## Returns
27+
28+
The created collection object.
29+
30+
<RequestExample>
31+
```go Go
32+
collection, err := client.Collections.Create(ctx,
33+
datasetID,
34+
"My-collection",
35+
)
36+
```
37+
</RequestExample>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Client.Collections.Get
3+
sidebarTitle: Collections.Get
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func (collectionClient) Get(
9+
ctx context.Context,
10+
datasetID uuid.UUID,
11+
name string,
12+
) (*datasets.Collection, error)
13+
```
14+
15+
Get a dataset by its slug.
16+
17+
## Parameters
18+
19+
<ParamField path="datasetID" type="uuid.UUID">
20+
The id of the dataset
21+
</ParamField>
22+
<ParamField path="name" type="string">
23+
The name of the collection
24+
</ParamField>
25+
26+
## Returns
27+
28+
The created collection object.
29+
30+
<RequestExample>
31+
```go Go
32+
collection, err := client.Collections.Get(ctx,
33+
datasetID,
34+
"My-collection",
35+
)
36+
```
37+
</RequestExample>
38+
39+
## Errors
40+
41+
<ParamField path="not_found" type="No such dataset">
42+
The specified dataset does not exist.
43+
</ParamField>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Client.Collections.GetOrCreate
3+
sidebarTitle: Collections.GetOrCreate
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func (collectionClient) GetOrCreate(
9+
ctx context.Context,
10+
datasetID uuid.UUID,
11+
name string,
12+
) (*datasets.Collection, error)
13+
```
14+
15+
Get or create a collection by its name. If the collection does not exist, it will be created.
16+
17+
## Parameters
18+
19+
<ParamField path="datasetID" type="uuid.UUID">
20+
The id of the dataset
21+
</ParamField>
22+
<ParamField path="name" type="string">
23+
The name of the collection
24+
</ParamField>
25+
26+
## Returns
27+
28+
A collection object.
29+
30+
<RequestExample>
31+
```go Go
32+
collection, err := client.Collections.GetOrCreate(ctx,
33+
datasetID,
34+
"My-collection",
35+
)
36+
```
37+
</RequestExample>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Client.Collections.List
3+
sidebarTitle: Collections.List
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func (collectionClient) List(
9+
ctx context.Context,
10+
datasetID uuid.UUID,
11+
) ([]*datasets.Collection, error)
12+
```
13+
14+
List the available collections in a dataset.
15+
16+
## Parameters
17+
18+
<ParamField path="datasetID" type="uuid.UUID">
19+
The id of the dataset
20+
</ParamField>
21+
22+
## Returns
23+
24+
A list of collection objects.
25+
26+
<RequestExample>
27+
```go Go
28+
collections, err := client.Collections.List(ctx,
29+
datasetID,
30+
)
31+
```
32+
</RequestExample>
33+
34+
## Errors
35+
36+
<ParamField path="not_found" type="No such dataset">
37+
The specified dataset does not exist.
38+
</ParamField>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Client.Datapoints.Delete
3+
sidebarTitle: Datapoints.Delete
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func (datapointClient) Delete(
9+
ctx context.Context,
10+
collectionID uuid.UUID,
11+
datapoints any,
12+
) (int64, error)
13+
```
14+
15+
Delete data points from a collection.
16+
17+
Data points are identified and deleted by their ids.
18+
19+
## Parameters
20+
21+
<ParamField path="collectionID" type="uuid.UUID">
22+
The id of the collection
23+
</ParamField>
24+
<ParamField path="datapoints" type="[]proto.Message">
25+
The datapoints to delete from the collection
26+
</ParamField>
27+
28+
## Returns
29+
30+
The number of data points that were deleted.
31+
32+
<RequestExample>
33+
```go Go
34+
var datapoints []*v1.Sentinel1Sar
35+
// assuming the slice is filled with datapoints
36+
37+
numDeleted, err := client.Datapoints.Delete(ctx,
38+
collectionID,
39+
datapoints,
40+
)
41+
```
42+
</RequestExample>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Client.Datapoints.DeleteIDs
3+
sidebarTitle: Datapoints.DeleteIDs
4+
icon: layer-group
5+
---
6+
7+
```go
8+
func (datapointClient) DeleteIDs(
9+
ctx context.Context,
10+
collectionID uuid.UUID,
11+
datapointIDs []uuid.UUID,
12+
) (int64, error)
13+
```
14+
15+
Delete data points from a collection.
16+
17+
## Parameters
18+
19+
<ParamField path="collectionID" type="uuid.UUID">
20+
The id of the collection
21+
</ParamField>
22+
<ParamField path="datapointIDs" type="[]uuid.UUID">
23+
The ids of the data points to delete from the collection
24+
</ParamField>
25+
26+
## Returns
27+
28+
The number of data points that were deleted.
29+
30+
<RequestExample>
31+
```go Go
32+
numDeleted, err := client.Datapoints.DeleteIDs(ctx,
33+
collectionID,
34+
[]uuid.UUID{
35+
uuid.MustParse("0195c87a-49f6-5ffa-e3cb-92215d057ea6"),
36+
uuid.MustParse("0195c87b-bd0e-3998-05cf-af6538f34957"),
37+
},
38+
)
39+
```
40+
</RequestExample>

0 commit comments

Comments
 (0)