commercetools 1.19.2 published on Friday, Mar 7, 2025 by labd
commercetools.getType
Explore with Pulumi AI
Fetches type information
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as commercetools from "@pulumi/commercetools";
const existingType = commercetools.getType({
key: "test",
});
const test = new commercetools.Channel("test", {
key: "test",
roles: ["ProductDistribution"],
custom: {
typeId: existingType.then(existingType => existingType.id),
fields: {
"my-field": "foobar",
},
},
});
import pulumi
import pulumi_commercetools as commercetools
existing_type = commercetools.get_type(key="test")
test = commercetools.Channel("test",
key="test",
roles=["ProductDistribution"],
custom={
"type_id": existing_type.id,
"fields": {
"my-field": "foobar",
},
})
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/commercetools/commercetools"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
existingType, err := commercetools.LookupType(ctx, &commercetools.LookupTypeArgs{
Key: "test",
}, nil)
if err != nil {
return err
}
_, err = commercetools.NewChannel(ctx, "test", &commercetools.ChannelArgs{
Key: pulumi.String("test"),
Roles: pulumi.StringArray{
pulumi.String("ProductDistribution"),
},
Custom: &commercetools.ChannelCustomArgs{
TypeId: pulumi.String(existingType.Id),
Fields: pulumi.StringMap{
"my-field": pulumi.String("foobar"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Commercetools = Pulumi.Commercetools;
return await Deployment.RunAsync(() =>
{
var existingType = Commercetools.GetType.Invoke(new()
{
Key = "test",
});
var test = new Commercetools.Channel("test", new()
{
Key = "test",
Roles = new[]
{
"ProductDistribution",
},
Custom = new Commercetools.Inputs.ChannelCustomArgs
{
TypeId = existingType.Apply(getTypeResult => getTypeResult.Id),
Fields =
{
{ "my-field", "foobar" },
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.commercetools.CommercetoolsFunctions;
import com.pulumi.commercetools.inputs.GetTypeArgs;
import com.pulumi.commercetools.Channel;
import com.pulumi.commercetools.ChannelArgs;
import com.pulumi.commercetools.inputs.ChannelCustomArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var existingType = CommercetoolsFunctions.getType(GetTypeArgs.builder()
.key("test")
.build());
var test = new Channel("test", ChannelArgs.builder()
.key("test")
.roles("ProductDistribution")
.custom(ChannelCustomArgs.builder()
.typeId(existingType.applyValue(getTypeResult -> getTypeResult.id()))
.fields(Map.of("my-field", "foobar"))
.build())
.build());
}
}
resources:
test:
type: commercetools:Channel
properties:
key: test
roles:
- ProductDistribution
custom:
typeId: ${existingType.id}
fields:
my-field: foobar
variables:
existingType:
fn::invoke:
function: commercetools:getType
arguments:
key: test
Using getType
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getType(args: GetTypeArgs, opts?: InvokeOptions): Promise<GetTypeResult>
function getTypeOutput(args: GetTypeOutputArgs, opts?: InvokeOptions): Output<GetTypeResult>
def get_type(key: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetTypeResult
def get_type_output(key: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetTypeResult]
func LookupType(ctx *Context, args *LookupTypeArgs, opts ...InvokeOption) (*LookupTypeResult, error)
func LookupTypeOutput(ctx *Context, args *LookupTypeOutputArgs, opts ...InvokeOption) LookupTypeResultOutput
> Note: This function is named LookupType
in the Go SDK.
public static class GetType
{
public static Task<GetTypeResult> InvokeAsync(GetTypeArgs args, InvokeOptions? opts = null)
public static Output<GetTypeResult> Invoke(GetTypeInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetTypeResult> getType(GetTypeArgs args, InvokeOptions options)
public static Output<GetTypeResult> getType(GetTypeArgs args, InvokeOptions options)
fn::invoke:
function: commercetools:index/getType:getType
arguments:
# arguments dictionary
The following arguments are supported:
- Key string
- Key of the custom type
- Key string
- Key of the custom type
- key String
- Key of the custom type
- key string
- Key of the custom type
- key str
- Key of the custom type
- key String
- Key of the custom type
getType Result
The following output properties are available:
Package Details
- Repository
- commercetools labd/terraform-provider-commercetools
- License
- Notes
- This Pulumi package is based on the
commercetools
Terraform Provider.