@Test public void createWorkspaceVariables() throws Exception{ Map<String,Map<String,String>> createWorkspaceVariablesResult= WorkspaceVariableImpl.createWorkspaceVariables(getTerraformWorkspaceVariableInputs); assertEquals(0,createWorkspaceVariablesResult.size()); }
@NotNull public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception { String workspaceVariableName; String workspaceVariableValue; String hcl; String workspaceVariableCategory; Map<String, Map<String, String>> createWorkspaceVariableMap = new HashMap<>(); JSONParser parser = new JSONParser(); final HttpClientInputs httpClientInputs = new HttpClientInputs(); final TerraformCommonInputs commonInputs = terraformWorkspaceVariableInputs.getCommonInputs(); httpClientInputs.setUrl(createWorkspaceVariableUrl(terraformWorkspaceVariableInputs)); setCommonHttpInputs(httpClientInputs, commonInputs); httpClientInputs.setAuthType(ANONYMOUS); httpClientInputs.setMethod(POST); httpClientInputs.setContentType(APPLICATION_VND_API_JSON); httpClientInputs.setHeaders(getAuthHeaders(commonInputs.getAuthToken())); if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty() & !terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson().isEmpty()) { String sensitiveWorkspaceVariableValue; JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); sensitiveWorkspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(sensitiveWorkspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty()) { JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else { JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(workspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } }
WorkspaceVariableImpl { @NotNull public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception { String workspaceVariableName; String workspaceVariableValue; String hcl; String workspaceVariableCategory; Map<String, Map<String, String>> createWorkspaceVariableMap = new HashMap<>(); JSONParser parser = new JSONParser(); final HttpClientInputs httpClientInputs = new HttpClientInputs(); final TerraformCommonInputs commonInputs = terraformWorkspaceVariableInputs.getCommonInputs(); httpClientInputs.setUrl(createWorkspaceVariableUrl(terraformWorkspaceVariableInputs)); setCommonHttpInputs(httpClientInputs, commonInputs); httpClientInputs.setAuthType(ANONYMOUS); httpClientInputs.setMethod(POST); httpClientInputs.setContentType(APPLICATION_VND_API_JSON); httpClientInputs.setHeaders(getAuthHeaders(commonInputs.getAuthToken())); if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty() & !terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson().isEmpty()) { String sensitiveWorkspaceVariableValue; JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); sensitiveWorkspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(sensitiveWorkspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty()) { JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else { JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(workspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } } }
WorkspaceVariableImpl { @NotNull public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception { String workspaceVariableName; String workspaceVariableValue; String hcl; String workspaceVariableCategory; Map<String, Map<String, String>> createWorkspaceVariableMap = new HashMap<>(); JSONParser parser = new JSONParser(); final HttpClientInputs httpClientInputs = new HttpClientInputs(); final TerraformCommonInputs commonInputs = terraformWorkspaceVariableInputs.getCommonInputs(); httpClientInputs.setUrl(createWorkspaceVariableUrl(terraformWorkspaceVariableInputs)); setCommonHttpInputs(httpClientInputs, commonInputs); httpClientInputs.setAuthType(ANONYMOUS); httpClientInputs.setMethod(POST); httpClientInputs.setContentType(APPLICATION_VND_API_JSON); httpClientInputs.setHeaders(getAuthHeaders(commonInputs.getAuthToken())); if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty() & !terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson().isEmpty()) { String sensitiveWorkspaceVariableValue; JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); sensitiveWorkspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(sensitiveWorkspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty()) { JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else { JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(workspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } }  }
WorkspaceVariableImpl { @NotNull public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception { String workspaceVariableName; String workspaceVariableValue; String hcl; String workspaceVariableCategory; Map<String, Map<String, String>> createWorkspaceVariableMap = new HashMap<>(); JSONParser parser = new JSONParser(); final HttpClientInputs httpClientInputs = new HttpClientInputs(); final TerraformCommonInputs commonInputs = terraformWorkspaceVariableInputs.getCommonInputs(); httpClientInputs.setUrl(createWorkspaceVariableUrl(terraformWorkspaceVariableInputs)); setCommonHttpInputs(httpClientInputs, commonInputs); httpClientInputs.setAuthType(ANONYMOUS); httpClientInputs.setMethod(POST); httpClientInputs.setContentType(APPLICATION_VND_API_JSON); httpClientInputs.setHeaders(getAuthHeaders(commonInputs.getAuthToken())); if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty() & !terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson().isEmpty()) { String sensitiveWorkspaceVariableValue; JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); sensitiveWorkspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(sensitiveWorkspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty()) { JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else { JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(workspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } }  @NotNull static Map<String, String> createWorkspaceVariable(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static Map<String, Map<String, String>> updateWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static Map<String, String> getWorkspaceVariablesOperationOutput(String workspaceVariablesJson, String sensitiveWorkspaceVariablesJson, Map<String, Map<String, String>> result); @NotNull static Map<String, String> listWorkspaceVariables(@NotNull final TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static String listWorkspaceVariablesUrl(@NotNull final TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static String getWorkspaceVariablePath(@NotNull final TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); static Map<String, String> updateWorkspaceVariable(@NotNull final TerraformWorkspaceVariableInputs updateWorkspaceVariableInputs); @NotNull static Map<String, String> deleteWorkspaceVariable(@NotNull final TerraformWorkspaceVariableInputs deleteWorkspaceVariableInputs); @NotNull static String getWorkspaceVariablesPath(@NotNull final TerraformWorkspaceVariableInputs updateWorkspaceVariableInputs); @NotNull static String createWorkspaceVariableRequestBody(TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static String updateWorkspaceVariableRequestBody(TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); }
WorkspaceVariableImpl { @NotNull public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception { String workspaceVariableName; String workspaceVariableValue; String hcl; String workspaceVariableCategory; Map<String, Map<String, String>> createWorkspaceVariableMap = new HashMap<>(); JSONParser parser = new JSONParser(); final HttpClientInputs httpClientInputs = new HttpClientInputs(); final TerraformCommonInputs commonInputs = terraformWorkspaceVariableInputs.getCommonInputs(); httpClientInputs.setUrl(createWorkspaceVariableUrl(terraformWorkspaceVariableInputs)); setCommonHttpInputs(httpClientInputs, commonInputs); httpClientInputs.setAuthType(ANONYMOUS); httpClientInputs.setMethod(POST); httpClientInputs.setContentType(APPLICATION_VND_API_JSON); httpClientInputs.setHeaders(getAuthHeaders(commonInputs.getAuthToken())); if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty() & !terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson().isEmpty()) { String sensitiveWorkspaceVariableValue; JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); sensitiveWorkspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(sensitiveWorkspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty()) { JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson()); JSONObject createWorkspaceVariableJson; for (int i = 0; i < createWorkspaceVariableJsonArray.size(); i++) { createWorkspaceVariableJson = (JSONObject) createWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .workspaceVariableValue(workspaceVariableValue) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("false").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } else { JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson()); JSONObject createSensitiveWorkspaceVariableJson; for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) { createSensitiveWorkspaceVariableJson = (JSONObject) createSensitiveWorkspaceVariableJsonArray.get(i); workspaceVariableName = (String) createSensitiveWorkspaceVariableJson.get("propertyName"); workspaceVariableValue = (String) createSensitiveWorkspaceVariableJson.get("propertyValue"); hcl = Boolean.toString((boolean) createSensitiveWorkspaceVariableJson.get("HCL")); workspaceVariableCategory = (String) createSensitiveWorkspaceVariableJson.get("Category"); terraformWorkspaceVariableInputs = terraformWorkspaceVariableInputs.builder() .workspaceVariableName(workspaceVariableName) .sensitiveWorkspaceVariableValue(workspaceVariableValue) .workspaceVariableValue(EMPTY) .workspaceVariableCategory(workspaceVariableCategory) .hcl(hcl) .workspaceId(terraformWorkspaceVariableInputs.getWorkspaceId()) .sensitive("true").build(); httpClientInputs.setBody(createWorkspaceVariableRequestBody(terraformWorkspaceVariableInputs)); createWorkspaceVariableMap.put(workspaceVariableName, new HttpClientService().execute(httpClientInputs)); } return createWorkspaceVariableMap; } }  @NotNull static Map<String, String> createWorkspaceVariable(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static Map<String, Map<String, String>> updateWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static Map<String, String> getWorkspaceVariablesOperationOutput(String workspaceVariablesJson, String sensitiveWorkspaceVariablesJson, Map<String, Map<String, String>> result); @NotNull static Map<String, String> listWorkspaceVariables(@NotNull final TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static String listWorkspaceVariablesUrl(@NotNull final TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static String getWorkspaceVariablePath(@NotNull final TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); static Map<String, String> updateWorkspaceVariable(@NotNull final TerraformWorkspaceVariableInputs updateWorkspaceVariableInputs); @NotNull static Map<String, String> deleteWorkspaceVariable(@NotNull final TerraformWorkspaceVariableInputs deleteWorkspaceVariableInputs); @NotNull static String getWorkspaceVariablesPath(@NotNull final TerraformWorkspaceVariableInputs updateWorkspaceVariableInputs); @NotNull static String createWorkspaceVariableRequestBody(TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs); @NotNull static String updateWorkspaceVariableRequestBody(TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs);  }