### Generate Overlay Example Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Example of how to use the GenerateOverlay method with API key authentication. Ensure you replace placeholder values with your actual API key and comparison data. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) if err != nil { log.Fatal(err) } if res.OverlayCompareResponse != nil { // handle response } } ``` -------------------------------- ### Install Speakeasy SDK Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Add the Speakeasy SDK as a dependency to your Go project. ```bash go get github.com/speakeasy-api/speakeasy/internal/studio/sdk ``` -------------------------------- ### Generate Overlay with Speakeasy SDK Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/USAGE.md Example of generating an overlay using the Speakeasy SDK. Ensure you replace placeholder values with your actual API key and comparison data. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) if err != nil { log.Fatal(err) } if res.OverlayCompareResponse != nil { // handle response } } ``` -------------------------------- ### Install Speakeasy Agent Skills Source: https://github.com/speakeasy-api/speakeasy/blob/main/README.md Install the Speakeasy agent skills package using npm. This command adds the necessary skills for AI coding agents to interact with Speakeasy. ```bash npx skills add speakeasy-api/agent-skills ``` -------------------------------- ### Speakeasy Agent Skills Usage Examples Source: https://github.com/speakeasy-api/speakeasy/blob/main/README.md Examples of how to invoke Speakeasy agent skills. These commands are used within AI coding agents to perform specific Speakeasy-related tasks. ```bash /speakeasy:start-new-sdk-project # Initialize a new SDK project ``` ```bash /speakeasy:validate-openapi-spec # Validate an OpenAPI spec ``` ```bash /speakeasy:regenerate-sdk # Re-run SDK generation ``` -------------------------------- ### Get Last Run Result with Speakeasy SDK Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/run/README.md Retrieve the output of the last generation run. Ensure you have initialized the SDK with your API key and are using a valid context. ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Run.GetLastResult(ctx) if err != nil { log.Fatal(err) } if res.RunResponse != nil { defer res.RunResponse.Close() for res.RunResponse.Next() { event := res.RunResponse.Value() log.Print(event) // Handle the event } } } ``` -------------------------------- ### Suggest Method Names Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/suggest/README.md Use this snippet to suggest method names for the current source using the Speakeasy SDK. Ensure you have initialized the SDK with your API key. ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Suggest.MethodNames(ctx) if err != nil { log.Fatal(err) } if res.SuggestResponse != nil { // handle response } } ``` -------------------------------- ### Rerun Generation with Speakeasy SDK Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/run/README.md Initiate a new generation process, optionally disconnecting existing connections. The SDK must be configured with security credentials and a context. ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Run.ReRun(ctx, components.RunRequestBody{ Disconnect: true, }) if err != nil { log.Fatal(err) } if res.RunResponse != nil { defer res.RunResponse.Close() for res.RunResponse.Next() { event := res.RunResponse.Value() log.Print(event) // Handle the event } } } ``` -------------------------------- ### Override Server URL Per-Client Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Initialize the SDK client with a custom server URL using the `WithServerURL` option. This is useful for testing or connecting to a specific instance of the API. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithServerURL("http://localhost:8080"), sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) if err != nil { log.Fatal(err) } if res.OverlayCompareResponse != nil { // handle response } } ``` -------------------------------- ### Set Templated Server URL Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/models/operations/option.md Use WithTemplatedServerURL to provide a server URL with dynamic parameters. Ensure all template parameters are supplied in the map. ```go operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ "host": "api.example.com", "port": "8080", }) ``` -------------------------------- ### Set Alternative Server URL Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/models/operations/option.md Use WithServerURL to provide a static, alternative server URL for API requests. ```go operations.WithServerURL("http://api.example.com") ``` -------------------------------- ### Suggest Method Names Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/suggest/README.md Suggests method names for the current source code. ```APIDOC ## Suggest Method Names ### Description Suggests method names for the current source code. ### Method POST ### Endpoint /v1/suggest/methodnames ### Parameters #### Query Parameters - **opts** (array of operations.Option) - Optional - The options for this request. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **SuggestResponse** (operations.SuggestMethodNamesResponse) - The response from the suggest method names operation. #### Response Example ```json { "example": "response body" } ``` ### Errors - **sdkerrors.SDKError** - 4XX, 5XX - */* ``` -------------------------------- ### Custom HTTP Client with Timeout Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Replace the default HTTP client with a custom one to configure timeouts, cookies, proxies, or custom headers. The custom client must implement the `HTTPClient` interface. ```go import ( "net/http" "time" "github.com/myorg/your-go-sdk" ) var ( httpClient = &http.Client{Timeout: 30 * time.Second} sdkClient = sdk.New(sdk.WithClient(httpClient)) ) ``` -------------------------------- ### Customize Retry Configuration Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/models/operations/option.md Use WithRetries to configure retry behavior for methods that support it. This allows fine-tuning of backoff strategies and connection error handling. ```go operations.WithRetries(retry.Config{ Strategy: "backoff", Backoff: retry.BackoffStrategy{ InitialInterval: 500 * time.Millisecond, MaxInterval: 60 * time.Second, Exponent: 1.5, MaxElapsedTime: 5 * time.Minute, }, RetryConnectionErrors: true, }) ``` -------------------------------- ### Perform Health Check Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/health/README.md This Go code snippet demonstrates how to initialize the Speakeasy SDK with an API key and perform a health check. It includes handling the response and iterating through any returned events. ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Health.Check(ctx) if err != nil { log.Fatal(err) } if res.HealthResponse != nil { defer res.HealthResponse.Close() for res.HealthResponse.Next() { event := res.HealthResponse.Value() log.Print(event) // Handle the event } } } ``` -------------------------------- ### Configure Default Retries for the Entire SDK Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Override the default retry strategy for all supported operations by using the WithRetryConfig option during SDK initialization. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/retry" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithRetryConfig( retry.Config{ Strategy: "backoff", Backoff: &retry.BackoffStrategy{ InitialInterval: 1, MaxInterval: 50, Exponent: 1.1, MaxElapsedTime: 100, }, RetryConnectionErrors: false, }), sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) if err != nil { log.Fatal(err) } if res.OverlayCompareResponse != nil { // handle response } } ``` -------------------------------- ### GenerateOverlay Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/sdk/README.md Generates an overlay by comparing two YAML files. This operation allows users to visualize differences between two versions of a configuration or specification. ```APIDOC ## GenerateOverlay Generate an overlay from two yaml files ### Description Generates an overlay by comparing two YAML files. This operation allows users to visualize differences between two versions of a configuration or specification. ### Method Not explicitly defined, but implied to be a client-side SDK method call. ### Endpoint Not applicable for SDK method. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **request** (components.OverlayCompareRequestBody) - Required - The request object to use for the request. - **before** (string) - Required - The content of the first YAML file. - **after** (string) - Required - The content of the second YAML file. ### Request Example ```go res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) ``` ### Response #### Success Response - **OverlayCompareResponse** (*components.OverlayCompareResponse) - Contains the generated overlay data. #### Response Example (Response structure depends on the `OverlayCompareResponse` type, not fully detailed in source) ### Errors - **sdkerrors.SDKError** - 4XX, 5XX - An error occurred during the operation. ``` -------------------------------- ### GenerateOverlayResponse Structure Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/models/operations/generateoverlayresponse.md Details the fields available in the GenerateOverlayResponse, which includes HTTP metadata and an optional overlay comparison response. ```APIDOC ## GenerateOverlayResponse ### Description Represents the response from the GenerateOverlay operation. It contains HTTP metadata and an optional overlay comparison response. ### Fields #### HTTPMeta - **Type**: [components.HTTPMetadata](../../models/components/httpmetadata.md) - **Required**: Yes - **Description**: N/A #### OverlayCompareResponse - **Type**: [*components.OverlayCompareResponse](../../models/components/overlaycompareresponse.md) - **Required**: No - **Description**: Successful response ``` -------------------------------- ### GetRunResponse Structure Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/models/operations/getrunresponse.md Details the fields available in the GetRunResponse object, which includes HTTP metadata and the run response. ```APIDOC ## GetRunResponse ### Description Represents the response from a GetRun operation, including HTTP metadata and the actual run response. ### Fields #### HTTPMeta - **Type**: [components.HTTPMetadata](../../models/components/httpmetadata.md) - **Required**: Yes - **Description**: N/A #### RunResponse - **Type**: stream.EventStream[components.RunResponse] - **Required**: No - **Description**: Successful response ``` -------------------------------- ### Override Server Port Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Override the default server port when initializing the SDK client instance using the WithPort option. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithPort("21809"), sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) if err != nil { log.Fatal(err) } if res.OverlayCompareResponse != nil { // handle response } } ``` -------------------------------- ### Handle SDK Errors Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Handle potential errors returned by SDK operations. By default, API errors return sdkerrors.SDKError. Custom error responses may also be returned. ```go package main import ( "context" "errors" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/sdkerrors" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }) if err != nil { var e *sdkerrors.SDKError if errors.As(err, &e) { // handle error log.Fatal(e.Error()) } } } ``` -------------------------------- ### Configure Retries for a Single API Call Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Override the default retry strategy for a specific API call by providing a retry.Config object using the WithRetries option. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/retry" "log" "models/operations" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.GenerateOverlay(ctx, components.OverlayCompareRequestBody{ Before: "", After: "", }, operations.WithRetries( retry.Config{ Strategy: "backoff", Backoff: &retry.BackoffStrategy{ InitialInterval: 1, MaxInterval: 50, Exponent: 1.1, MaxElapsedTime: 100, }, RetryConnectionErrors: false, })) if err != nil { log.Fatal(err) } if res.OverlayCompareResponse != nil { // handle response } } ``` -------------------------------- ### Consume Server-Sent Event Stream Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/README.md Handle server-sent events by iterating over the stream exposed by certain operations. The loop terminates when the server closes the connection. ```go package main import ( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Health.Check(ctx) if err != nil { log.Fatal(err) } if res.HealthResponse != nil { defer res.HealthResponse.Close() for res.HealthResponse.Next() { event := res.HealthResponse.Value() log.Print(event) // Handle the event } } } ``` -------------------------------- ### ReRun Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/run/README.md Regenerates the currently selected targets. This operation can be used to re-execute a generation process, potentially with updated configurations. ```APIDOC ## ReRun ### Description Regenerate the currently selected targets. ### Method POST (inferred from SDK method name and typical usage with a request body) ### Endpoint /v1/run/rerun (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **request** (*components.RunRequestBody*) - Required - The request object containing parameters for the rerun operation. Example: `{ "disconnect": true }` ### Request Example ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "github.com/speakeasy-api/speakeasy/internal/studio/sdk/models/components" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Run.ReRun(ctx, components.RunRequestBody{ Disconnect: true, }) if err != nil { log.Fatal(err) } if res.RunResponse != nil { defer res.RunResponse.Close() for res.RunResponse.Next() { event := res.RunResponse.Value() log.Print(event) // Handle the event } } } ``` ### Response #### Success Response (200) - **RunResponse** (*operations.RunResponse*) - The response indicating the status of the rerun operation. #### Response Example (Response structure not detailed in source, refer to `operations.RunResponse` model) ### Errors - **sdkerrors.SDKError** - Returned for 4XX or 5XX errors. ``` -------------------------------- ### Check Health Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/health/README.md Checks the CLI health and returns relevant information. This operation is useful for verifying the operational status of the Speakeasy CLI. ```APIDOC ## Check Health ### Description Checks the CLI health and returns relevant information. This operation is useful for verifying the operational status of the Speakeasy CLI. ### Method N/A (SDK Method) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Health.Check(ctx) if err != nil { log.Fatal(err) } if res.HealthResponse != nil { defer res.HealthResponse.Close() for res.HealthResponse.Next() { event := res.HealthResponse.Value() log.Print(event) // Handle the event } } } ``` ### Response #### Success Response **operations.CheckHealthResponse, error** #### Response Example None provided in source. ### Errors #### SDK Errors - **sdkerrors.SDKError**: Handles 4XX and 5XX status codes with any content type. ``` -------------------------------- ### GetLastResult Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/sdks/run/README.md Retrieves the output of the last generation run. This method is useful for inspecting the results of a previous operation. ```APIDOC ## GetLastResult ### Description Get the output of the last run. ### Method GET (inferred from SDK method name and typical usage) ### Endpoint /v1/run/last (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go package main import( "context" "github.com/speakeasy-api/speakeasy/internal/studio/sdk" "log" ) func main() { ctx := context.Background() s := sdk.New( sdk.WithSecurity(""), ) res, err := s.Run.GetLastResult(ctx) if err != nil { log.Fatal(err) } if res.RunResponse != nil { defer res.RunResponse.Close() for res.RunResponse.Next() { event := res.RunResponse.Value() log.Print(event) // Handle the event } } } ``` ### Response #### Success Response (200) - **RunResponse** (*operations.GetRunResponse*) - The response containing the run results. #### Response Example (Response structure not detailed in source, refer to `operations.GetRunResponse` model) ### Errors - **sdkerrors.SDKError** - Returned for 4XX or 5XX errors. ``` -------------------------------- ### CheckHealthResponse Source: https://github.com/speakeasy-api/speakeasy/blob/main/internal/studio/sdk/docs/models/operations/checkhealthresponse.md The CheckHealthResponse model encapsulates the result of a health check, providing HTTP metadata and the actual health status. ```APIDOC ## CheckHealthResponse ### Description Represents the response from a health check operation, including HTTP metadata and the health status. ### Fields #### HTTPMeta - **Type**: [components.HTTPMetadata](../../models/components/httpmetadata.md) - **Required**: Yes - **Description**: N/A #### HealthResponse - **Type**: stream.EventStream[components.HealthResponse] - **Required**: No - **Description**: Successful response ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.