pulumi/tests/testdata/codegen/output-funcs/go/mypkg/getBastionShareableLink.go

103 lines
3.6 KiB
Go
Raw Normal View History

// Code generated by test DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package mypkg
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
2023-06-14 16:34:49 +00:00
"output-funcs/mypkg/internal"
)
// Response for all the Bastion Shareable Link endpoints.
// API Version: 2020-11-01.
func GetBastionShareableLink(ctx *pulumi.Context, args *GetBastionShareableLinkArgs, opts ...pulumi.InvokeOption) (*GetBastionShareableLinkResult, error) {
2023-06-14 16:34:49 +00:00
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetBastionShareableLinkResult
err := ctx.Invoke("mypkg::getBastionShareableLink", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
type GetBastionShareableLinkArgs struct {
// The name of the Bastion Host.
BastionHostName string `pulumi:"bastionHostName"`
// The name of the resource group.
ResourceGroupName string `pulumi:"resourceGroupName"`
// List of VM references.
Vms []BastionShareableLink `pulumi:"vms"`
}
// Response for all the Bastion Shareable Link endpoints.
type GetBastionShareableLinkResult struct {
// The URL to get the next set of results.
NextLink *string `pulumi:"nextLink"`
}
func GetBastionShareableLinkOutput(ctx *pulumi.Context, args GetBastionShareableLinkOutputArgs, opts ...pulumi.InvokeOption) GetBastionShareableLinkResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetBastionShareableLinkResultOutput, error) {
args := v.(GetBastionShareableLinkArgs)
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetBastionShareableLinkResult
secret, err := ctx.InvokePackageRaw("mypkg::getBastionShareableLink", args, &rv, "", opts...)
if err != nil {
return GetBastionShareableLinkResultOutput{}, err
[codegen/go] Update Go SDK function output to check for errors (#9274) * [codegen/go] Update Go SDK function output to check for errors Fixes https://github.com/pulumi/pulumi-aws/issues/1872. This should result in the following sample output in the Go SDK: ``` func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput { return pulumi.ToOutputWithContext(context.Background(), args). ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) { args := v.(GetPolicyDocumentArgs) r, err := GetPolicyDocument(ctx, &args, opts...) if err != nil { return nil, err } if r == nil { return nil, fmt.Errorf("expected either result or error to be nil, not both") } return *r, err }).(GetPolicyDocumentResultOutput) } ``` * Fix generated code panic on *nil (#9284) * [codegen/go] Update Go SDK function output to check for errors Fixes https://github.com/pulumi/pulumi-aws/issues/1872. This should result in the following sample output in the Go SDK: ``` func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput { return pulumi.ToOutputWithContext(context.Background(), args). ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) { args := v.(GetPolicyDocumentArgs) r, err := GetPolicyDocument(ctx, &args, opts...) if r != nil { s = *r } return s, err }).(GetPolicyDocumentResultOutput) } ``` * Alternate fix to safeguard dereferencing nil * Accept codegen changes in the test suite Co-authored-by: Guinevere Saenger <guinevere@pulumi.com> * Update CHANGELOG_PENDING.md Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
2022-03-25 03:11:53 +00:00
}
output := pulumi.ToOutput(rv).(GetBastionShareableLinkResultOutput)
if secret {
return pulumi.ToSecret(output).(GetBastionShareableLinkResultOutput), nil
}
return output, nil
}).(GetBastionShareableLinkResultOutput)
}
type GetBastionShareableLinkOutputArgs struct {
// The name of the Bastion Host.
BastionHostName pulumi.StringInput `pulumi:"bastionHostName"`
// The name of the resource group.
ResourceGroupName pulumi.StringInput `pulumi:"resourceGroupName"`
// List of VM references.
Vms BastionShareableLinkArrayInput `pulumi:"vms"`
}
func (GetBastionShareableLinkOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetBastionShareableLinkArgs)(nil)).Elem()
}
// Response for all the Bastion Shareable Link endpoints.
type GetBastionShareableLinkResultOutput struct{ *pulumi.OutputState }
func (GetBastionShareableLinkResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetBastionShareableLinkResult)(nil)).Elem()
}
func (o GetBastionShareableLinkResultOutput) ToGetBastionShareableLinkResultOutput() GetBastionShareableLinkResultOutput {
return o
}
func (o GetBastionShareableLinkResultOutput) ToGetBastionShareableLinkResultOutputWithContext(ctx context.Context) GetBastionShareableLinkResultOutput {
return o
}
func (o GetBastionShareableLinkResultOutput) ToOutput(ctx context.Context) pulumix.Output[GetBastionShareableLinkResult] {
return pulumix.Output[GetBastionShareableLinkResult]{
OutputState: o.OutputState,
}
}
// The URL to get the next set of results.
func (o GetBastionShareableLinkResultOutput) NextLink() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetBastionShareableLinkResult) *string { return v.NextLink }).(pulumi.StringPtrOutput)
}
func init() {
pulumi.RegisterOutputType(GetBastionShareableLinkResultOutput{})
}