Skip to content

Commit 64fbc06

Browse files
committed
Release v0.0.271
1 parent 41a5aa4 commit 64fbc06

File tree

4 files changed

+186
-13
lines changed

4 files changed

+186
-13
lines changed

client/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ package client
55
import (
66
core "github.com/fern-api/generator-exec-go/core"
77
logging "github.com/fern-api/generator-exec-go/logging"
8+
readme "github.com/fern-api/generator-exec-go/readme"
89
http "net/http"
910
)
1011

1112
type Client interface {
1213
Logging() logging.Client
14+
Readme() readme.Client
1315
}
1416

1517
func NewClient(opts ...core.ClientOption) Client {
@@ -22,6 +24,7 @@ func NewClient(opts ...core.ClientOption) Client {
2224
httpClient: options.HTTPClient,
2325
header: options.ToHeader(),
2426
loggingClient: logging.NewClient(opts...),
27+
readmeClient: readme.NewClient(opts...),
2528
}
2629
}
2730

@@ -30,8 +33,13 @@ type client struct {
3033
httpClient core.HTTPClient
3134
header http.Header
3235
loggingClient logging.Client
36+
readmeClient readme.Client
3337
}
3438

3539
func (c *client) Logging() logging.Client {
3640
return c.loggingClient
3741
}
42+
43+
func (c *client) Readme() readme.Client {
44+
return c.readmeClient
45+
}

core/client_option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
3636
headers := c.HTTPHeader.Clone()
3737
headers.Set("X-Fern-Language", "Go")
3838
headers.Set("X-Fern-SDK-Name", "github.com/fern-api/generator-exec-go")
39-
headers.Set("X-Fern-SDK-Version", "0.0.263")
39+
headers.Set("X-Fern-SDK-Version", "0.0.271")
4040
return headers
4141
}

readme.go

Lines changed: 121 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,133 @@
22

33
package generatorexec
44

5+
import (
6+
json "encoding/json"
7+
fmt "fmt"
8+
strconv "strconv"
9+
)
10+
11+
type BadgeType uint
12+
13+
const (
14+
BadgeTypeNpm BadgeType = iota + 1
15+
BadgeTypeMaven
16+
BadgeTypePypi
17+
BadgeTypeGo
18+
)
19+
20+
func (b BadgeType) String() string {
21+
switch b {
22+
default:
23+
return strconv.Itoa(int(b))
24+
case BadgeTypeNpm:
25+
return "NPM"
26+
case BadgeTypeMaven:
27+
return "MAVEN"
28+
case BadgeTypePypi:
29+
return "PYPI"
30+
case BadgeTypeGo:
31+
return "GO"
32+
}
33+
}
34+
35+
func (b BadgeType) MarshalJSON() ([]byte, error) {
36+
return []byte(fmt.Sprintf("%q", b.String())), nil
37+
}
38+
39+
func (b *BadgeType) UnmarshalJSON(data []byte) error {
40+
var raw string
41+
if err := json.Unmarshal(data, &raw); err != nil {
42+
return err
43+
}
44+
switch raw {
45+
case "NPM":
46+
value := BadgeTypeNpm
47+
*b = value
48+
case "MAVEN":
49+
value := BadgeTypeMaven
50+
*b = value
51+
case "PYPI":
52+
value := BadgeTypePypi
53+
*b = value
54+
case "GO":
55+
value := BadgeTypeGo
56+
*b = value
57+
}
58+
return nil
59+
}
60+
561
// The standard sections included in every generated README.md
6-
type Readme struct {
62+
//
63+
// # {{title}}
64+
// {{badge}} [Fern Badge]
65+
//
66+
// {{summary}}
67+
//
68+
// ## API Documentation
69+
//
70+
// API Reference Documentation is available {{here}}.
71+
//
72+
// ## Installation
73+
//
74+
// {{installation}}
75+
//
76+
// ## Usage
77+
//
78+
// {{usage}}
79+
//
80+
// ## Async Client
81+
//
82+
// {{asyncUsage}}
83+
//
84+
// ## Environments
85+
//
86+
// {{environments}}
87+
//
88+
// ## Custom URL
89+
//
90+
// {{customUrl}}
91+
//
92+
// ## Handling Errors
93+
//
94+
// {{errors}}
95+
//
96+
// ## Advanced: Setting Timeouts
97+
//
98+
// {{timeouts}}
99+
//
100+
// ## Advanced: Request Options
101+
//
102+
// {{requestOptions}}}
103+
//
104+
// ## Beta Status
105+
//
106+
// Some info about beta status.
107+
//
108+
// ## Contributing
109+
//
110+
// Some info about contributing.
111+
type GenerateReadmeRequest struct {
7112
// The title (e.g. Acme Python Library ...)
8113
Title string `json:"title"`
9114
// Badges rendered alongside the standard Fern badge
10-
Badges string `json:"badges"`
115+
Badge *BadgeType `json:"badge,omitempty"`
11116
// The summary included below the badges (e.g. The Acme Python library provides ...)
12117
Summary string `json:"summary"`
13-
// General requirements to use the SDK
14-
Requirements *string `json:"requirements,omitempty"`
118+
// Each requirement is rendered as a bulleted list
119+
Requirements []string `json:"requirements,omitempty"`
15120
// The installation steps
16-
Installation string `json:"installation"`
17-
// Describes how to instantiate the client (i.e. a code snippet)
18-
Instantiation string `json:"instantiation"`
19-
// Usage guide, extensible with Fern definition example annotations
121+
Installation *string `json:"installation,omitempty"`
122+
// Section describing how to instantiate the client (i.e. a code snippet)
20123
Usage string `json:"usage"`
21-
// The status of the SDK (e.g. beta)
22-
Status string `json:"status"`
23-
// The contributing guide; if not specified uses the default contributing notes
24-
Contributing *string `json:"contributing,omitempty"`
124+
// Section describing how to instantiate an async client
125+
AsyncUsage *string `json:"asyncUsage,omitempty"`
126+
// Section describing how to set timeouts
127+
Timeouts *string `json:"timeouts,omitempty"`
128+
// If multiple environments, a section for how to specify multiple environments
129+
Environments *string `json:"environments,omitempty"`
130+
// Section describing how to set a custom url
131+
CustomUrl *string `json:"customUrl,omitempty"`
132+
// Section describing how to set request options
133+
RequestOptions *string `json:"requestOptions,omitempty"`
25134
}

readme/client.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package readme
4+
5+
import (
6+
context "context"
7+
fmt "fmt"
8+
generatorexecgo "github.com/fern-api/generator-exec-go"
9+
core "github.com/fern-api/generator-exec-go/core"
10+
http "net/http"
11+
)
12+
13+
type Client interface {
14+
GenerateReadme(ctx context.Context, taskId generatorexecgo.TaskId, request *generatorexecgo.GenerateReadmeRequest) error
15+
}
16+
17+
func NewClient(opts ...core.ClientOption) Client {
18+
options := core.NewClientOptions()
19+
for _, opt := range opts {
20+
opt(options)
21+
}
22+
return &client{
23+
baseURL: options.BaseURL,
24+
httpClient: options.HTTPClient,
25+
header: options.ToHeader(),
26+
}
27+
}
28+
29+
type client struct {
30+
baseURL string
31+
httpClient core.HTTPClient
32+
header http.Header
33+
}
34+
35+
func (c *client) GenerateReadme(ctx context.Context, taskId generatorexecgo.TaskId, request *generatorexecgo.GenerateReadmeRequest) error {
36+
baseURL := ""
37+
if c.baseURL != "" {
38+
baseURL = c.baseURL
39+
}
40+
endpointURL := fmt.Sprintf(baseURL+"/"+"api/readme/%v", taskId)
41+
42+
if err := core.DoRequest(
43+
ctx,
44+
c.httpClient,
45+
endpointURL,
46+
http.MethodPost,
47+
request,
48+
nil,
49+
false,
50+
c.header,
51+
nil,
52+
); err != nil {
53+
return err
54+
}
55+
return nil
56+
}

0 commit comments

Comments
 (0)