1. Packages
  2. Commercetools Provider
  3. API Docs
  4. getType
commercetools 1.19.3 published on Friday, Apr 4, 2025 by labd

commercetools.getType

Explore with Pulumi AI

commercetools 1.19.3 published on Friday, Apr 4, 2025 by labd

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",
        },
    },
});
Copy
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",
        },
    })
Copy
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
	})
}
Copy
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" },
            },
        },
    });

});
Copy
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());

    }
}
Copy
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
Copy

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>
Copy
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]
Copy
func LookupType(ctx *Context, args *LookupTypeArgs, opts ...InvokeOption) (*LookupTypeResult, error)
func LookupTypeOutput(ctx *Context, args *LookupTypeOutputArgs, opts ...InvokeOption) LookupTypeResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetTypeResult> getType(GetTypeArgs args, InvokeOptions options)
public static Output<GetTypeResult> getType(GetTypeArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: commercetools:index/getType:getType
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Key This property is required. string
Key of the custom type
Key This property is required. string
Key of the custom type
key This property is required. String
Key of the custom type
key This property is required. string
Key of the custom type
key This property is required. str
Key of the custom type
key This property is required. String
Key of the custom type

getType Result

The following output properties are available:

Id string
ID of the custom type
Key string
Key of the custom type
Id string
ID of the custom type
Key string
Key of the custom type
id String
ID of the custom type
key String
Key of the custom type
id string
ID of the custom type
key string
Key of the custom type
id str
ID of the custom type
key str
Key of the custom type
id String
ID of the custom type
key String
Key of the custom type

Package Details

Repository
commercetools labd/terraform-provider-commercetools
License
Notes
This Pulumi package is based on the commercetools Terraform Provider.
commercetools 1.19.3 published on Friday, Apr 4, 2025 by labd