{
	"name": "FireIde.Core.VCAP.SetEndpointToken",
	"json": {
		"@scopeSet(input)": {
			"@input": null
		},
		"@scopeSet(vmc_token_file_path)": {
			"@concat": [
				{
					"@FireIde.Core.Env.Get(HOME)": null
				},
				"/.vmc_token"
			]
		},
		"@scopeSet(vmc_token_exists)": {
			"@FireIde.Core.Fs.PathExists": {
				"@get(vmc_token_file_path)": null
			}
		},
		"@if(vmc_token_exists)": {
			"@scopeSet(tokens)": {
				"@Commons.JSON.Parse": {
					"@FireIde.Core.Fs.ReadFile": {
						"@get(vmc_token_file_path)": null
					}
				}
			},
			"@Commons.Object.SetKey(tokens)": {
				"key": {
					"@get(input.endpoint)": null
				},
				"value": {
					"@get(input.token)": null
				}
			},
			"@FireIde.Core.Fs.UpdateFile": {
				"path": {
					"@get(vmc_token_file_path)": null
				},
				"content": {
					"@Commons.JSON.Stringify": {
						"@get(tokens)": null
					}
				}
			}
		},
		"@unless(vmc_token_exists)": {
			"@FireIde.Core.Fs.UpdateFile": {
				"path": {
					"@get(vmc_token_file_path)": null
				},
				"content": {
					"@scopeSet(tokens)": {},
					"@Commons.Object.SetKey(tokens)": {
						"key": {
							"@get(input.endpoint)": null
						},
						"value": {
							"@get(input.token)": null
						}
					},
					"@Commons.JSON.Stringify": {
						"@get(tokens)": null
					}
				}
			},
			"@return": true
		}
	}
}