packagemainimport("context""log""os""github.com/DataDog/cloudcraft-go")funcmain(){// Get the API key from the environment.
key,ok:=os.LookupEnv("CLOUDCRAFT_API_KEY")if!ok{log.Fatal("missing env var: CLOUDCRAFT_API_KEY")}// Create new Config to initialize a Client.
cfg:=cloudcraft.NewConfig(key)// Create a new Client instance with the given Config.
client,err:=cloudcraft.NewClient(cfg)iferr!=nil{log.Fatal(err)}// List all Azure accounts in the Cloudcraft account.
accounts,_,err:=client.Azure.List(context.Background())iferr!=nil{log.Fatal(err)}// Print the name of each account.
for_,account:=rangeaccounts{log.Println(account.Name)}}
The body of the request should contain the account properties in JSON format. The response contains the created account object, including the newly assigned ID for use with other API endpoints.
packagemainimport("context""log""os""github.com/DataDog/cloudcraft-go")funcmain(){// Get the API key from the environment.
key,ok:=os.LookupEnv("CLOUDCRAFT_API_KEY")if!ok{log.Fatal("missing env var: CLOUDCRAFT_API_KEY")}// Check if the command line arguments are correct.
iflen(os.Args)!=6{log.Fatalf("usage: %s <account-name> <app-id> <dir-id> <sub-id> <secret>",os.Args[0])}// Create new Config to initialize a Client.
cfg:=cloudcraft.NewConfig(key)// Create a new Client instance with the given Config.
client,err:=cloudcraft.NewClient(cfg)iferr!=nil{log.Fatal(err)}// Create a new Azure Account with the details coming from command line
// arguments.
account,_,err:=client.Azure.Create(context.Background(),&cloudcraft.AzureAccount{Name:os.Args[1],ApplicationID:os.Args[2],DirectoryID:os.Args[3],SubscriptionID:os.Args[4],ClientSecret:os.Args[5],})iferr!=nil{log.Fatal(err)}// Print the account ID.
log.Println(account.ID)}
OkHttpClientclient=newOkHttpClient().newBuilder().build();MediaTypemediaType=MediaType.parse("application/json");RequestBodybody=RequestBody.create(mediaType,"{\n \"name\": \"AWS account name (for example prod or staging)\",\n \"roleArn\": \"arn:aws:iam::1234567890:role/cloudcraft\"\n}\n");Requestrequest=newRequest.Builder().url("https://api.cloudcraft.co/azure/account").method("POST",body).addHeader("Content-Type","application/json").build();Responseresponse=client.newCall(request).execute();
packagemainimport("context""log""os""github.com/DataDog/cloudcraft-go")funcmain(){// Get the API key from the environment.
key,ok:=os.LookupEnv("CLOUDCRAFT_API_KEY")if!ok{log.Fatal("missing env var: CLOUDCRAFT_API_KEY")}// Show usage if the number of command line arguments is not correct.
iflen(os.Args)!=2{log.Fatalf("usage: %s <account-id>",os.Args[0])}// Create new Config to initialize a Client.
cfg:=cloudcraft.NewConfig(key)// Create a new Client instance with the given Config.
client,err:=cloudcraft.NewClient(cfg)iferr!=nil{log.Fatal(err)}// Delete the Azure account with the ID taken from a command line argument.
_,err=client.Azure.Delete(context.Background(),os.Args[1],)iferr!=nil{log.Fatal(err)}}
packagemainimport("context""log""os""github.com/DataDog/cloudcraft-go")funcmain(){// Get the API key from the environment.
key,ok:=os.LookupEnv("CLOUDCRAFT_API_KEY")if!ok{log.Fatal("missing env var: CLOUDCRAFT_API_KEY")}// Check if the command line arguments are correct.
iflen(os.Args)!=5{log.Fatalf("usage: %s <account-name> <app-id> <dir-id> <sub-id>",os.Args[0])}// Create new Config to initialize a Client.
cfg:=cloudcraft.NewConfig(key)// Create a new Client instance with the given Config.
client,err:=cloudcraft.NewClient(cfg)iferr!=nil{log.Fatal(err)}// Create a new Azure Account with the details coming from command line
// arguments.
_,err=client.Azure.Update(context.Background(),&cloudcraft.AzureAccount{Name:os.Args[1],ApplicationID:os.Args[2],DirectoryID:os.Args[3],SubscriptionID:os.Args[4],})iferr!=nil{log.Fatal(err)}}
Scan and render one region of an Azure account into a blueprint in JSON, SVG, PNG, PDF, or MxGraph format.
The time required to generate the snapshot depends on the number of resources in the Azure region.
The API behaves as a long poll, with a wait time of up to 120 seconds for the result. For most environments, the API call returns a blueprint. If the wait time is exceeded, a 202 Accepted response is returned with a {code: STILL_PROCESSING, retry: true ...} JSON body. The snapshot will continue processing in the background, and a retry will either immediately return the result or continue waiting.
filter: String. Render a subset of the Azure account. Accepts a filter expression as used on the Live tab in the web application. The filter expression terms must be separated by spaces. The terms are substrings to be matched, key-value pairs, logical operators, or parentheses. For example, `env=dev OR env=test`.
exclude: List of Strings. Exclude Azure services by name. For example, “azurevmss,azurensg” to exclude both Virtual Machine Scale Set and Network Security Groups. The service value is specified by the “type” field of Blueprint components.
label: Boolean. Automatically label all components. Defaults to true.
autoconnect: Boolean. Automatically connect all components. Defaults to true.
scale: Float. Scale relative to original size (1.0), for example, 0.5 for half or 2.0 for double size.
width: Number. Image width in pixels (for SVG, PNG, and PDF).
height: Number. Image height in pixels (for SVG, PNG, and PDF).
grid: Boolean. Enable or disable grid rendering.
transparent: Boolean. Enable or disable transparent background rendering.
landscape: Boolean. Enable or disable landscape paper format (PDF).
paperSize: String. Applies when the format is PDF. One of “Letter”, “Legal”, “Tabloid”, “Ledger”, “A0”, “A1”, “A2”, “A3”, “A4”, “A5”.
projection: String. The visual style of the diagram. One of “isometric” or “2d”.
theme: String. The color theme of the diagram. One of “light” or “dark”.
packagemainimport("context""log""os""github.com/DataDog/cloudcraft-go")funcmain(){// Get the API key from the environment.
key,ok:=os.LookupEnv("CLOUDCRAFT_API_KEY")if!ok{log.Fatal("missing env var: CLOUDCRAFT_API_KEY")}// Check if the command line arguments are correct.
iflen(os.Args)!=2{log.Fatalf("usage: %s <account-id>",os.Args[0])}// Create new Config to initialize a Client.
cfg:=cloudcraft.NewConfig(key)// Create a new Client instance with the given Config.
client,err:=cloudcraft.NewClient(cfg)iferr!=nil{log.Fatal(err)}// Create a new snapshot of the centralus region with the given account-id
// coming from a command line argument.
snapshot,_,err:=client.Azure.Snapshot(context.Background(),os.Args[1],"centralus","png",&cloudcraft.SnapshotParams{Width:1920,Height:1080,},)iferr!=nil{log.Fatal(err)}// Save the snapshot to a file.
iferr:=os.WriteFile("snapshot.png",snapshot,0o600);err!=nil{log.Fatal(err)}}