зеркало из https://github.com/Azure/ARO-RP.git
fixed json marshal issue
This commit is contained in:
Родитель
ba7da1dee3
Коммит
f13b7a9119
|
@ -8,7 +8,6 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
sdkcosmos "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
|
@ -34,45 +33,45 @@ type Billing interface {
|
|||
func NewBilling(ctx context.Context, dbc cosmosdb.DatabaseClient, dbName string, sqlResourceClient *sdkcosmos.SQLResourcesClient, location, resourceGroup, dbAccountName string) (Billing, error) {
|
||||
collc := cosmosdb.NewCollectionClient(dbc, dbName)
|
||||
|
||||
triggerResources := []*sdkcosmos.SQLTriggerResource{
|
||||
{
|
||||
ID: to.Ptr("setCreationBillingTimeStamp"),
|
||||
Body: to.Ptr(`function trigger() {
|
||||
var request = getContext().getRequest();
|
||||
var body = request.getBody();
|
||||
var date = new Date();
|
||||
var now = Math.floor(date.getTime() / 1000);
|
||||
var billingBody = body["billing"];
|
||||
if (!billingBody["creationTime"]) {
|
||||
billingBody["creationTime"] = now;
|
||||
}
|
||||
request.setBody(body);
|
||||
}`),
|
||||
TriggerOperation: to.Ptr(sdkcosmos.TriggerOperation("Create")),
|
||||
TriggerType: to.Ptr(sdkcosmos.TriggerType("Pre")),
|
||||
},
|
||||
{
|
||||
ID: to.Ptr("setDeletionBillingTimeStamp"),
|
||||
Body: to.Ptr(`function trigger() {
|
||||
var request = getContext().getRequest();
|
||||
var body = request.getBody();
|
||||
var date = new Date();
|
||||
var now = Math.floor(date.getTime() / 1000);
|
||||
var billingBody = body["billing"];
|
||||
if (!billingBody["creationTime"]) {
|
||||
billingBody["creationTime"] = now;
|
||||
}
|
||||
request.setBody(body);
|
||||
}`),
|
||||
TriggerOperation: to.Ptr(sdkcosmos.TriggerOperation("Replace")),
|
||||
TriggerType: to.Ptr(sdkcosmos.TriggerType("Pre")),
|
||||
},
|
||||
}
|
||||
// triggerResources := []*sdkcosmos.SQLTriggerResource{
|
||||
// {
|
||||
// ID: to.Ptr("setCreationBillingTimeStamp"),
|
||||
// Body: to.Ptr(`function trigger() {
|
||||
// var request = getContext().getRequest();
|
||||
// var body = request.getBody();
|
||||
// var date = new Date();
|
||||
// var now = Math.floor(date.getTime() / 1000);
|
||||
// var billingBody = body["billing"];
|
||||
// if (!billingBody["creationTime"]) {
|
||||
// billingBody["creationTime"] = now;
|
||||
// }
|
||||
// request.setBody(body);
|
||||
// }`),
|
||||
// TriggerOperation: to.Ptr(sdkcosmos.TriggerOperation("Create")),
|
||||
// TriggerType: to.Ptr(sdkcosmos.TriggerType("Pre")),
|
||||
// },
|
||||
// {
|
||||
// ID: to.Ptr("setDeletionBillingTimeStamp"),
|
||||
// Body: to.Ptr(`function trigger() {
|
||||
// var request = getContext().getRequest();
|
||||
// var body = request.getBody();
|
||||
// var date = new Date();
|
||||
// var now = Math.floor(date.getTime() / 1000);
|
||||
// var billingBody = body["billing"];
|
||||
// if (!billingBody["creationTime"]) {
|
||||
// billingBody["creationTime"] = now;
|
||||
// }
|
||||
// request.setBody(body);
|
||||
// }`),
|
||||
// TriggerOperation: to.Ptr(sdkcosmos.TriggerOperation("Replace")),
|
||||
// TriggerType: to.Ptr(sdkcosmos.TriggerType("Pre")),
|
||||
// },
|
||||
// }
|
||||
|
||||
err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collBilling)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collBilling)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
documentClient := cosmosdb.NewBillingDocumentClient(collc, collBilling)
|
||||
return NewBillingWithProvidedClient(documentClient), nil
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
|
@ -36,25 +35,25 @@ type Monitors interface {
|
|||
func NewMonitors(ctx context.Context, dbc cosmosdb.DatabaseClient, dbName string, sqlResourceClient *armcosmos.SQLResourcesClient, location, resourceGroup, dbAccountName string) (Monitors, error) {
|
||||
collc := cosmosdb.NewCollectionClient(dbc, dbName)
|
||||
|
||||
triggerResources := []*armcosmos.SQLTriggerResource{
|
||||
{
|
||||
ID: to.Ptr("renewLease"),
|
||||
Body: to.Ptr(`function trigger() {
|
||||
var request = getContext().getRequest();
|
||||
var body = request.getBody();
|
||||
var date = new Date();
|
||||
body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 60;
|
||||
request.setBody(body);
|
||||
}`),
|
||||
TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
},
|
||||
}
|
||||
// triggerResources := []*armcosmos.SQLTriggerResource{
|
||||
// {
|
||||
// ID: to.Ptr("renewLease"),
|
||||
// Body: to.Ptr(`function trigger() {
|
||||
// var request = getContext().getRequest();
|
||||
// var body = request.getBody();
|
||||
// var date = new Date();
|
||||
// body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 60;
|
||||
// request.setBody(body);
|
||||
// }`),
|
||||
// TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
// TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
// },
|
||||
// }
|
||||
|
||||
err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collMonitors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collMonitors)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return &monitors{
|
||||
c: cosmosdb.NewMonitorDocumentClient(collc, collMonitors),
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
||||
|
@ -61,24 +60,24 @@ type OpenShiftClusters interface {
|
|||
func NewOpenShiftClusters(ctx context.Context, dbc cosmosdb.DatabaseClient, dbName string, sqlResourceClient *armcosmos.SQLResourcesClient, location, resourceGroup, dbAccountName string) (OpenShiftClusters, error) {
|
||||
collc := cosmosdb.NewCollectionClient(dbc, dbName)
|
||||
|
||||
triggerResources := []*armcosmos.SQLTriggerResource{
|
||||
{
|
||||
ID: to.Ptr("renewLease"),
|
||||
Body: to.Ptr(`function trigger() {
|
||||
var request = getContext().getRequest();
|
||||
var body = request.getBody();
|
||||
var date = new Date();
|
||||
body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 60;
|
||||
request.setBody(body);
|
||||
}`),
|
||||
TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
},
|
||||
}
|
||||
err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collOpenShiftClusters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// triggerResources := []*armcosmos.SQLTriggerResource{
|
||||
// {
|
||||
// ID: to.Ptr("renewLease"),
|
||||
// Body: to.Ptr(`function trigger() {
|
||||
// var request = getContext().getRequest();
|
||||
// var body = request.getBody();
|
||||
// var date = new Date();
|
||||
// body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 60;
|
||||
// request.setBody(body);
|
||||
// }`),
|
||||
// TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
// TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
// },
|
||||
// }
|
||||
// err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collOpenShiftClusters)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
documentClient := cosmosdb.NewOpenShiftClusterDocumentClient(collc, collOpenShiftClusters)
|
||||
return NewOpenShiftClustersWithProvidedClient(documentClient, collc, uuid.DefaultGenerator.Generate(), uuid.DefaultGenerator), nil
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v2"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
|
@ -41,37 +40,37 @@ type Subscriptions interface {
|
|||
func NewSubscriptions(ctx context.Context, dbc cosmosdb.DatabaseClient, dbName string, sqlResourceClient *armcosmos.SQLResourcesClient, location, resourceGroup, dbAccountName string) (Subscriptions, error) {
|
||||
collc := cosmosdb.NewCollectionClient(dbc, dbName)
|
||||
|
||||
triggerResources := []*armcosmos.SQLTriggerResource{
|
||||
{
|
||||
ID: to.Ptr("renewLease"),
|
||||
Body: to.Ptr(`function trigger() {
|
||||
var request = getContext().getRequest();
|
||||
var body = request.getBody();
|
||||
var date = new Date();
|
||||
body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 60;
|
||||
request.setBody(body);
|
||||
}`),
|
||||
TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
},
|
||||
{
|
||||
ID: to.Ptr("retryLater"),
|
||||
Body: to.Ptr(`function trigger() {
|
||||
var request = getContext().getRequest();
|
||||
var body = request.getBody();
|
||||
var date = new Date();
|
||||
body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 600;
|
||||
request.setBody(body);
|
||||
}`),
|
||||
TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
},
|
||||
}
|
||||
// triggerResources := []*armcosmos.SQLTriggerResource{
|
||||
// {
|
||||
// ID: to.Ptr("renewLease"),
|
||||
// Body: to.Ptr(`function trigger() {
|
||||
// var request = getContext().getRequest();
|
||||
// var body = request.getBody();
|
||||
// var date = new Date();
|
||||
// body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 60;
|
||||
// request.setBody(body);
|
||||
// }`),
|
||||
// TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
// TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
// },
|
||||
// {
|
||||
// ID: to.Ptr("retryLater"),
|
||||
// Body: to.Ptr(`function trigger() {
|
||||
// var request = getContext().getRequest();
|
||||
// var body = request.getBody();
|
||||
// var date = new Date();
|
||||
// body["leaseExpires"] = Math.floor(date.getTime() / 1000) + 600;
|
||||
// request.setBody(body);
|
||||
// }`),
|
||||
// TriggerOperation: to.Ptr(armcosmos.TriggerOperation(cosmosdb.TriggerOperationAll)),
|
||||
// TriggerType: to.Ptr(armcosmos.TriggerType(cosmosdb.TriggerTypePre)),
|
||||
// },
|
||||
// }
|
||||
|
||||
err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collSubscriptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// err := createTriggers(ctx, sqlResourceClient, triggerResources, resourceGroup, dbName, dbAccountName, location, collSubscriptions)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
documentClient := cosmosdb.NewSubscriptionDocumentClient(collc, collSubscriptions)
|
||||
return NewSubscriptionsWithProvidedClient(documentClient, uuid.DefaultGenerator.Generate()), nil
|
||||
|
|
|
@ -262,118 +262,112 @@
|
|||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "renewLease",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), parameters('databaseName'), 'Subscriptions')]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/Subscriptions/renewLease')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]"
|
||||
]
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "renewLease",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "retryLater",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 600;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), parameters('databaseName'), 'Subscriptions')]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/Subscriptions/retryLater')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]"
|
||||
]
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 600;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "retryLater",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "setCreationBillingTimeStamp",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "Create",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), parameters('databaseName'), 'Billing')]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/Billing/setCreationBillingTimeStamp')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]"
|
||||
]
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "setCreationBillingTimeStamp",
|
||||
"triggerOperation": "Create",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "setDeletionBillingTimeStamp",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "Replace",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), parameters('databaseName'), 'Billing')]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/Billing/setDeletionBillingTimeStamp')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]"
|
||||
]
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "setDeletionBillingTimeStamp",
|
||||
"triggerOperation": "Replace",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "renewLease",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), parameters('databaseName'), 'OpenShiftClusters')]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/OpenShiftClusters/renewLease')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]"
|
||||
]
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "renewLease",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "renewLease",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/Monitors/renewLease')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]"
|
||||
]
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), parameters('databaseName'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), parameters('databaseName'), 'Monitors')]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', parameters('databaseName'), '/Monitors/renewLease')]",
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "renewLease",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -941,124 +941,118 @@
|
|||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "renewLease",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), 'ARO', 'Subscriptions')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/Subscriptions/renewLease')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "renewLease",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), 'ARO', 'Subscriptions')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "retryLater",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 600;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/Subscriptions/retryLater')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 600;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "retryLater",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), 'ARO', 'Billing')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "setCreationBillingTimeStamp",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "Create",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/Billing/setCreationBillingTimeStamp')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "setCreationBillingTimeStamp",
|
||||
"triggerOperation": "Create",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), 'ARO', 'Billing')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "setDeletionBillingTimeStamp",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "Replace",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/Billing/setDeletionBillingTimeStamp')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tvar now = Math.floor(date.getTime() / 1000);\n\t\t\t\tvar billingBody = body[\"billing\"];\n\t\t\t\tif (!billingBody[\"creationTime\"]) {\n\t\t\t\t\tbillingBody[\"creationTime\"] = now;\n\t\t\t\t}\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "setDeletionBillingTimeStamp",
|
||||
"triggerOperation": "Replace",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), 'ARO', 'OpenShiftClusters')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "renewLease",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/OpenShiftClusters/renewLease')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
]
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "renewLease",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"Properties": {
|
||||
"Resource": {
|
||||
"ID": "renewLease",
|
||||
"Body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"TriggerOperation": "All",
|
||||
"TriggerType": "Pre"
|
||||
},
|
||||
"Options": null
|
||||
},
|
||||
"location": "[resourceGroup().location]",
|
||||
"ID": null,
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/Monitors/renewLease')]",
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
"apiVersion": "2023-04-15",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), 'ARO')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), 'ARO', 'Monitors')]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccountName'))]"
|
||||
]
|
||||
],
|
||||
"location": "[resourceGroup().location]",
|
||||
"name": "[concat(parameters('databaseAccountName'), '/', 'ARO', '/Monitors/renewLease')]",
|
||||
"properties": {
|
||||
"resource": {
|
||||
"body": "function trigger() {\n\t\t\t\tvar request = getContext().getRequest();\n\t\t\t\tvar body = request.getBody();\n\t\t\t\tvar date = new Date();\n\t\t\t\tbody[\"leaseExpires\"] = Math.floor(date.getTime() / 1000) + 60;\n\t\t\t\trequest.setBody(body);\n\t\t\t}",
|
||||
"id": "renewLease",
|
||||
"triggerOperation": "All",
|
||||
"triggerType": "Pre"
|
||||
}
|
||||
},
|
||||
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
|
|
|
@ -1241,7 +1241,6 @@ func (g *generator) rpCosmosDBTriggers(databaseName, containerName, triggerID, t
|
|||
TriggerOperation: &triggerOperation,
|
||||
TriggerType: &triggerType,
|
||||
},
|
||||
// Options: &sdkcosmos.CreateUpdateOptions{},
|
||||
},
|
||||
Name: to.StringPtr("[concat(parameters('databaseAccountName'), '/', " + databaseName + ", '/" + containerName + "/" + triggerID + "')]"),
|
||||
Type: to.StringPtr("Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers"),
|
||||
|
@ -1250,7 +1249,7 @@ func (g *generator) rpCosmosDBTriggers(databaseName, containerName, triggerID, t
|
|||
APIVersion: azureclient.APIVersion("Microsoft.DocumentDB"),
|
||||
DependsOn: []string{
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), " + databaseName + ")]",
|
||||
// "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccountName'), concat(" + databaseName + ", '/" + containerName + "'))]",
|
||||
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('databaseAccountName'), " + databaseName + ", '" + containerName + "')]",
|
||||
},
|
||||
Type: "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/triggers",
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ func (r *Resource) MarshalJSON() ([]byte, error) {
|
|||
b, err = r.Resource.(*sdkcosmos.SQLDatabaseCreateUpdateParameters).MarshalJSON()
|
||||
} else if reflect.TypeOf(r.Resource) == reflect.TypeOf(&sdkcosmos.SQLContainerCreateUpdateParameters{}) {
|
||||
b, err = r.Resource.(*sdkcosmos.SQLContainerCreateUpdateParameters).MarshalJSON()
|
||||
} else if reflect.TypeOf(r.Resource) == reflect.TypeOf(&sdkcosmos.SQLTriggerCreateUpdateParameters{}) {
|
||||
b, err = r.Resource.(*sdkcosmos.SQLTriggerCreateUpdateParameters).MarshalJSON()
|
||||
}
|
||||
} else if strings.HasPrefix(r.Type, "Microsoft.DocumentDB/databaseAccounts") {
|
||||
b, err = r.Resource.(*sdkcosmos.DatabaseAccountCreateUpdateParameters).MarshalJSON()
|
||||
|
|
Загрузка…
Ссылка в новой задаче