Skip to content

Commit

Permalink
Promote Microsoft.IoTOperations Private Preview Specs to Public Previ…
Browse files Browse the repository at this point in the history
…ew Repo (Azure#29374)

* init

* copy over private specs

* spellcheck

* compile

* remove rule

* ..

* ..

* resync examples and fix model validation

* resource naming in examples

* prettier

* ..

* add suppression for failing pipeline
  • Loading branch information
hmmorales authored Aug 2, 2024
1 parent f2da46e commit eb323c0
Show file tree
Hide file tree
Showing 87 changed files with 14,505 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,16 @@
"words": [
"systemversionname"
]
},
{
"filename": "**/specification/iotoperations/resource-manager/Microsoft.IoTOperations/**/*.json",
"words": [
"akri",
"opcua",
"websockets",
"opentelemetry",
"parquet"
]
}
],
"enableFiletypes": [
Expand All @@ -1397,4 +1407,5 @@
"ignoreWords": [
"trafficcontrollerspec"
]

}
26 changes: 26 additions & 0 deletions specification/iotoperations/IoTOperations.Management/eng/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Developer Documentation

## Pre-requisite

run this in the root of the azure-rest-api-specs/-pr directory
```bash
npm i
```
oav-generate
```bash
npm i -g oav
```
typespec compiler
```bash
npm install -g @typespec/compiler
```
## When contributing
When making changes to these specs please run this script before pushing changes to your remote branch.
```bash
./openapi-script.sh
```

The script will:
1. re-compile the typespec files
2. generate examples
3. prettify the directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash

############################################################################################################
# #
# Run this script in the /specifications/iotoperations directory to generate the specs and the examples. #
# #
############################################################################################################
cd ../..
if [ ! -d "resource-manager" ] || [ ! -d "IoTOperations.Management" ]; then
echo "Please run this script in the /specifications/iotoperations/IoTOperations.Management/eng directory."
exit 1
fi

echo "Deleting the examples in the resource-manager directory and the management directory..."
rm -r resource-manager/Microsoft.IoTOperations/preview/2024-07-01-preview/examples
rm -r IoTOperations.Management/examples/2024-07-01-preview

echo "Generating the specs and the examples!"

# Compile all the typespecs the iotoperations directory
echo "Compiling the typespecs in the iotoperations directory..."
npx tsp compile IoTOperations.Management/.

# Generate examples for all the openapi specs
echo "Generating examples for all the openapi specs..."
oav generate-examples resource-manager/Microsoft.IoTOperations/preview/2024-07-01-preview/iotoperations.json --max -p

# Search each example file and replace the default string with resource-name123
for file in resource-manager/Microsoft.IoTOperations/preview/2024-07-01-preview/examples/*.json; do
jq 'walk(if type == "string" and . == "Replace this value with a string matching RegExp ^[a-z0-9][a-z0-9-]*[a-z0-9]$" then "resource-name123" else . end)' $file > temp.json && mv temp.json $file
jq 'walk(if type == "string" and . == "Replace this value with a string matching RegExp ^[0-9]+[KMGTPE]$" then "500M" else . end)' $file > temp.json && mv temp.json $file
jq 'walk(if type == "string" and . == "Replace this value with a string matching RegExp ^https://.*$" then "https://www.example.com" else . end)' $file > temp.json && mv temp.json $file
jq 'walk(if type == "string" and . == "Replace this value with a string matching RegExp .+\\..+\\.kusto\\.windows\\.net" then "<cluster>.<region>.kusto.windows.net" else . end)' $file > temp.json && mv temp.json $file
jq 'walk(if type == "string" and . == "Replace this value with a string matching RegExp .+\\.blob\\.core\\.windows\\.net" then "<account>.blob.core.windows.net" else . end)' $file > temp.json && mv temp.json $file
jq 'walk(if type == "string" and . == "Replace this value with a string matching RegExp .+\\.fabric\\.microsoft\\.com" then "https://<host>.fabric.microsoft.com" else . end)' $file > temp.json && mv temp.json $file
done

for file in resource-manager/Microsoft.IoTOperations/preview/2024-07-01-preview/examples/*.json; do

# The following Jq commands replace ids with properly formatted ARM Ids
operationId=$(jq -r '.operationId' $file)
if [[ $operationId == Instance* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("Instance") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == BrokerAuthentication* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("BrokerAuthentication") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/authentications/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == BrokerAuthorization* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("BrokerAuthorization") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/authorizations/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == BrokerListener* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("BrokerListener") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/listeners/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == Broker* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("Broker") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == DataFlowProfile* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("DataFlowProfile") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/dataflowProfiles/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == DataFlowEndpoint* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("DataFlowEndpoint") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/dataflowEndpoints/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
elif [[ $operationId == DataFlow* ]]; then
jq --arg operationId "$operationId" 'walk(if type == "object" and .id? then if $operationId | startswith("DataFlow") then .id = "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/dataflowProfiles/resource-name123/dataflows/resource-name123" else . end else . end)' $file > temp.json && mv temp.json $file
fi

# The following Jq command chops down numbers that are greater than 10000 to 10000, the OAV generate examples tool will not respect the min/max value required by typespec
jq 'walk(if type == "number" then . % 10000 else . end)' $file > temp.json && mv temp.json $file
done

# Copy the examples to the management directory
echo "Copying the examples to the management directory..."
cp -r resource-manager/Microsoft.IoTOperations/preview/2024-07-01-preview/examples/. IoTOperations.Management/examples/2024-07-01-preview/

# Recompile the typespecs in the management directory
echo "Recompiling the typespecs in the management directory..."
npx tsp compile IoTOperations.Management/.
npx tsv IoTOperations.Management/.

# Prettier
echo "Running prettier..."
npx prettier --write **/*.json

echo "Completed generating the specs and the examples!"
echo "Done!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"title": "BrokerAuthentication_CreateOrUpdate",
"operationId": "BrokerAuthentication_CreateOrUpdate",
"parameters": {
"api-version": "2024-07-01-preview",
"subscriptionId": "9265A271-C9EC-4648-9AF8-B575759AB43E",
"resourceGroupName": "rgiotoperations",
"instanceName": "aio-instance",
"brokerName": "aio-broker",
"authenticationName": "resource-name123",
"resource": {
"properties": {
"authenticationMethods": [
{
"method": "ServiceAccountToken",
"serviceAccountToken": {
"audiences": [
"aio-mq"
]
}
}
]
},
"extendedLocation": {
"name": "ycsyubcxttlusbhfdqaynmkaatnbyv",
"type": "CustomLocation"
}
}
},
"responses": {
"200": {
"body": {
"properties": {
"authenticationMethods": [
{
"method": "ServiceAccountToken",
"serviceAccountToken": {
"audiences": [
"aio-mq"
]
}
}
],
"provisioningState": "Succeeded"
},
"extendedLocation": {
"name": "ycsyubcxttlusbhfdqaynmkaatnbyv",
"type": "CustomLocation"
},
"id": "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/authentications/resource-name123",
"name": "gjfyvwhgwouiqfxml",
"type": "iebmxuxbwumiobejywgyh",
"systemData": {
"createdBy": "ijyjtvjpfwt",
"createdByType": "User",
"createdAt": "2024-06-26T23:49:23.909Z",
"lastModifiedBy": "fkfrkewn",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-06-26T23:49:23.909Z"
}
}
},
"201": {
"headers": {
"Azure-AsyncOperation": "https://contoso.com/operationstatus"
},
"body": {
"properties": {
"authenticationMethods": [
{
"method": "ServiceAccountToken",
"serviceAccountToken": {
"audiences": [
"aio-mq"
]
}
}
],
"provisioningState": "Succeeded"
},
"extendedLocation": {
"name": "ycsyubcxttlusbhfdqaynmkaatnbyv",
"type": "CustomLocation"
},
"id": "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/authentications/resource-name123",
"name": "gjfyvwhgwouiqfxml",
"type": "iebmxuxbwumiobejywgyh",
"systemData": {
"createdBy": "ijyjtvjpfwt",
"createdByType": "User",
"createdAt": "2024-06-26T23:49:23.909Z",
"lastModifiedBy": "fkfrkewn",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-06-26T23:49:23.909Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"title": "BrokerAuthentication_Delete",
"operationId": "BrokerAuthentication_Delete",
"parameters": {
"api-version": "2024-07-01-preview",
"subscriptionId": "27CFC271-1989-4D65-B02C-90A010ACD0E4",
"resourceGroupName": "rgiotoperations",
"instanceName": "resource-name123",
"brokerName": "resource-name123",
"authenticationName": "resource-name123"
},
"responses": {
"202": {
"headers": {
"location": "https://contoso.com/operationstatus"
}
},
"204": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"title": "BrokerAuthentication_Get",
"operationId": "BrokerAuthentication_Get",
"parameters": {
"api-version": "2024-07-01-preview",
"subscriptionId": "27CFC271-1989-4D65-B02C-90A010ACD0E4",
"resourceGroupName": "rgiotoperations",
"instanceName": "resource-name123",
"brokerName": "resource-name123",
"authenticationName": "resource-name123"
},
"responses": {
"200": {
"body": {
"properties": {
"authenticationMethods": [
{
"method": "Custom",
"custom": {
"auth": {
"x509": {
"secretRef": "hmuambcnwvar"
}
},
"caCertConfigMap": "d",
"endpoint": "https://www.example.com",
"headers": {
"key3025": "tngcschtuoccvyvsg"
}
},
"serviceAccountToken": {
"audiences": [
"gznfb"
]
},
"x509Credentials": {
"authorizationAttributes": {
"key5349": {
"attributes": {
"key5251": "piumfpteiounuiqv"
},
"subject": "p"
}
},
"trustedClientCaCert": "sfmbypdtbszeyhoxvsopnecdjce"
}
}
],
"provisioningState": "Succeeded"
},
"extendedLocation": {
"name": "yubkzmgux",
"type": "CustomLocation"
},
"id": "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/authentications/resource-name123",
"name": "hwolou",
"type": "rgmumpmxeeglhdkrrwcdxjdeujhp",
"systemData": {
"createdBy": "no",
"createdByType": "User",
"createdAt": "2024-07-31T16:41:28.972Z",
"lastModifiedBy": "qommjdtfplptszwsertvljkqbie",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-07-31T16:41:28.972Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"title": "BrokerAuthentication_ListByResourceGroup",
"operationId": "BrokerAuthentication_ListByResourceGroup",
"parameters": {
"api-version": "2024-07-01-preview",
"subscriptionId": "27CFC271-1989-4D65-B02C-90A010ACD0E4",
"resourceGroupName": "rgiotoperations",
"instanceName": "resource-name123",
"brokerName": "resource-name123"
},
"responses": {
"200": {
"body": {
"value": [
{
"properties": {
"authenticationMethods": [
{
"method": "Custom",
"custom": {
"auth": {
"x509": {
"secretRef": "hmuambcnwvar"
}
},
"caCertConfigMap": "d",
"endpoint": "https://www.example.com",
"headers": {
"key3025": "tngcschtuoccvyvsg"
}
},
"serviceAccountToken": {
"audiences": [
"gznfb"
]
},
"x509Credentials": {
"authorizationAttributes": {
"key5349": {
"attributes": {
"key5251": "piumfpteiounuiqv"
},
"subject": "p"
}
},
"trustedClientCaCert": "sfmbypdtbszeyhoxvsopnecdjce"
}
}
],
"provisioningState": "Succeeded"
},
"extendedLocation": {
"name": "yubkzmgux",
"type": "CustomLocation"
},
"id": "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/brokers/resource-name123/authentications/resource-name123",
"name": "hwolou",
"type": "rgmumpmxeeglhdkrrwcdxjdeujhp",
"systemData": {
"createdBy": "no",
"createdByType": "User",
"createdAt": "2024-07-31T16:41:28.972Z",
"lastModifiedBy": "qommjdtfplptszwsertvljkqbie",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-07-31T16:41:28.972Z"
}
}
],
"nextLink": "https://microsoft.com/alyli"
}
}
}
}
Loading

0 comments on commit eb323c0

Please sign in to comment.