diff --git a/.gitignore b/.gitignore index e16c3ad..9b84dc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# making sure ot not commit the SDK libs +libs/* + # Compiled class file *.class diff --git a/application/readme.md b/application/readme.md index 5126eae..c55eaeb 100644 --- a/application/readme.md +++ b/application/readme.md @@ -136,8 +136,12 @@ Ensure that you have: | APICP_RUNTIME_CAPACITY_VALUE | *Optional*. The approximate estimate of the throughput that a runtime can handle for the specified duration.| Default value: *500000*

If you do not specify a value for this property, the default value is considered. | | APICP_RUNTIME_CAPACITY_UNIT | *Optional*. Choose the unit of duration in which the capacity must be defined. | Possible values are as follows:

If you do not specify a value for this property, the default value is considered.| | APICP_RUNTIME_TYPE | *Mandatory*. The runtime type. | Ensure to verify if the runtime type exists in API Control Plane. If it does not exist, use the Runtime Type Management Service REST API to add the runtime type. For details, see [How to create the runtime type?](../docs/runtime_service_mgmt_api.md) | -| APICP_LOG_LEVEL | *Optional*. The level of logs to be captured.|

If you do not specify a value for this property, the default value is considered.| - +| APICP_RUNTIME_NAME | *Optional*. api runtime name | if not specified, will be set to the actual name of the Azure api gateway | +| APICP_RUNTIME_DESCRIPTION | *Optional*. Description about the Azure API Gateway name | if not specified, no description added | +| APICP_RUNTIME_REGION | *Optional*. The region for the Azure API Gateway name | if not specified, the value will be set from the actual Azure region for the Azure API Gateway | +| APICP_RUNTIME_LOCATION | *Optional*. The location for the Azure API Gateway name | if not specified, the value will be set from the actual Azure location for the Azure API Gateway | +| APICP_RUNTIME_TAGS | *Optional*. Tags for the Azure API Gateway name | if not specified, the value will be set to the tags set in Azure API Gateway | +| APICP_LOG_LEVEL | *Optional*. The level of logs to be captured.|

If you do not specify a value for this property, the default value is considered.| 2. Run the following command: diff --git a/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/RuntimeProperties.java b/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/RuntimeProperties.java index 0fa4946..620f0b1 100644 --- a/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/RuntimeProperties.java +++ b/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/RuntimeProperties.java @@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; +import java.util.Set; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; @@ -19,6 +20,30 @@ @Setter @Validated public class RuntimeProperties { + /** + * Name for the Azure API Gateway - if not specified, the value will be set from the actual name of the Azure API Gateway + */ + private String name; + + /** + * Description about the Azure API Gateway name + */ + private String description; + + /** + * The region for the Azure API Gateway name - if not specified, the value will be set from the actual Azure region for the Azure API Gateway + */ + private String region; + + /** + * The location for the Azure API Gateway name - if not specified, the value will be set from the actual Azure location for the Azure API Gateway + */ + private String location; + + /** + * Tags for the Azure API Gateway name + */ + private Set tags; /** * The API Management Service transaction capacity is represented as number in here diff --git a/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/SDKConfigUtil.java b/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/SDKConfigUtil.java index fdfedaf..f97e432 100644 --- a/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/SDKConfigUtil.java +++ b/application/src/main/java/com/softwareag/controlplane/agent/azure/configuration/SDKConfigUtil.java @@ -14,6 +14,7 @@ import com.softwareag.controlplane.agentsdk.api.config.TlsConfig; import com.softwareag.controlplane.agentsdk.model.Capacity; import com.softwareag.controlplane.agentsdk.model.Runtime; +import java.util.Set; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Component; @@ -58,26 +59,46 @@ public static ControlPlaneConfig controlPlaneConfig(AgentProperties agentPropert public static RuntimeConfig runtimeConfig(AzureProperties azureProperties,RuntimeProperties runtimeProperties, AzureManagersHolder managerHolder){ - Location location = managerHolder.getAzureResourceManager().subscriptions() + //name block + String runtimeName = ObjectUtils.isEmpty(runtimeProperties.getName()) ? azureProperties.getApiManagementServiceName() : runtimeProperties.getName(); + + //region block + Region azureRegion = Region.fromName(managerHolder.getApiService().regionName()); + String runtimeRegion = ObjectUtils.isEmpty(runtimeProperties.getRegion()) && ObjectUtils.isNotEmpty(azureRegion) ? + azureRegion.toString() : runtimeProperties.getRegion(); + + //location block + Location azureLocation = managerHolder.getAzureResourceManager().subscriptions() .getById(azureProperties.getSubscriptionId()) - .getLocationByRegion(Region.fromName(managerHolder.getApiService().regionName())); + .getLocationByRegion(azureRegion); + String runtimeLocation = ObjectUtils.isEmpty(runtimeProperties.getLocation()) && ObjectUtils.isNotEmpty(azureLocation) ? + azureLocation.physicalLocation() : runtimeProperties.getLocation(); + + //tags block + Set runtimeTags = ObjectUtils.isEmpty(runtimeProperties.getTags()) ? AzureAgentUtil.convertTags(managerHolder.getApiService().tags()) : runtimeProperties.getTags(); + //capacity block Capacity capacity = null; if(ObjectUtils.isNotEmpty(runtimeProperties.getCapacityValue())) { capacity = new Capacity(); capacity.setUnit(Capacity.TimeUnit.valueOf(runtimeProperties.getCapacityUnit())); capacity.setValue(Long.parseLong(runtimeProperties.getCapacityValue())); } + // runtime ID = subscriptionId_serviceName String runtimeId = azureProperties.getSubscriptionId() + Constants.UNDERSCORE + azureProperties.getApiManagementServiceName(); - return new RuntimeConfig.Builder(runtimeId, - azureProperties.getApiManagementServiceName(), runtimeProperties.getType(), + + String runtimeHost = String.format("https://%s.developer.azure-api.net", azureProperties.getApiManagementServiceName()); + + return new RuntimeConfig.Builder(runtimeId, runtimeName, runtimeProperties.getType(), Runtime.DeploymentType.PUBLIC_CLOUD) - .region(managerHolder.getApiService().regionName()) - .location(location.physicalLocation()) - .tags(AzureAgentUtil.convertTags(managerHolder.getApiService().tags())) + .description(runtimeProperties.getDescription()) + .region(runtimeRegion) + .location(runtimeLocation) + .tags(runtimeTags) .capacity(capacity) + .host(runtimeHost) .build(); } diff --git a/application/src/main/resources/application.properties b/application/src/main/resources/application.properties index 0a1dbb7..9f8985a 100644 --- a/application/src/main/resources/application.properties +++ b/application/src/main/resources/application.properties @@ -58,6 +58,16 @@ apicp.runtime.capacity-value=500000 apicp.runtime.capacity-unit=PER_DAY # Pre-requisite for creating your API Management as Runtime into Control Plane is to create Runtime type in Control Plane. apicp.runtime.type=azure +# api runtime name (if not specified, will be set to the actual name of the Azure api gateway) +apicp.runtime.name= +# Description about the Azure API Gateway name +apicp.runtime.description= +# The region for the Azure API Gateway name - if not specified, the value will be set from the actual Azure region for the Azure API Gateway +apicp.runtime.region= +# The location for the Azure API Gateway name - if not specified, the value will be set from the actual Azure location for the Azure API Gateway +apicp.runtime.location= +# Tags for the Azure API Gateway name - if not specified, the value will be set to the tags set in Azure API Gateway +apicp.runtime.tags= # SDK Log level as Configured such as ALL , ERROR , INFO , TRACE apicp.log-level=ALL ##################################### API Control Plane SDK properties - End ##################################### \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755