1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
# coding: utf-8
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
# Current Operation Coverage:
# GremlinResources: 16/16
import unittest
import azure.mgmt.cosmosdb
from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer, ResourceGroupPreparer
AZURE_LOCATION = 'eastus'
class MgmtCosmosDBTest(AzureMgmtTestCase):
def setUp(self):
super(MgmtCosmosDBTest, self).setUp()
self.mgmt_client = self.create_mgmt_client(
azure.mgmt.cosmosdb.CosmosDBManagementClient
)
@unittest.skip('hard to test')
@ResourceGroupPreparer(location=AZURE_LOCATION)
def test_gremlin_resource(self, resource_group):
RESOURCE_GROUP = resource_group.name
ACCOUNT_NAME = "myaccountxxyyzzz"
DATABASE_NAME = "myDatabase"
GRAPH_NAME = "myGraph"
#--------------------------------------------------------------------------
# /DatabaseAccounts/put/CosmosDBDatabaseAccountCreateMin[put]
#--------------------------------------------------------------------------
BODY = {
"location": AZURE_LOCATION,
"kind": "GlobalDocumentDB",
"database_account_offer_type": "Standard",
"locations": [
{
"location_name": "eastus",
"is_zone_redundant": False,
"failover_priority": "0"
},
],
"capabilities": [
{
"name": "EnableGremlin"
}
],
"api_properties": {}
}
result = self.mgmt_client.database_accounts.begin_create_or_update(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, create_update_parameters=BODY)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/put/CosmosDBGremlinDatabaseCreateUpdate[put]
#--------------------------------------------------------------------------
BODY = {
"location": AZURE_LOCATION,
"resource": {
"id": DATABASE_NAME
},
"options": {
"throughput": "2000"
}
}
result = self.mgmt_client.gremlin_resources.begin_create_update_gremlin_database(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, create_update_gremlin_database_parameters=BODY)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/put/CosmosDBGremlinGraphCreateUpdate[put]
#--------------------------------------------------------------------------
BODY = {
"location": AZURE_LOCATION,
"resource": {
"id": GRAPH_NAME,
"indexing_policy": {
"indexing_mode": "Consistent",
"automatic": True,
"included_paths": [
{
"path": "/*",
"indexes": [
{
"kind": "Range",
"data_type": "String",
"precision": "-1"
},
{
"kind": "Range",
"data_type": "Number",
"precision": "-1"
}
]
}
],
"excluded_paths": []
},
"partition_key": {
"paths": [
"/AccountNumber"
],
"kind": "Hash"
},
"default_ttl": "100",
"conflict_resolution_policy": {
"mode": "LastWriterWins",
"conflict_resolution_path": "/path"
}
},
"options": {
"throughput": "2000"
}
}
result = self.mgmt_client.gremlin_resources.begin_create_update_gremlin_graph(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME, create_update_gremlin_graph_parameters=BODY)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/put/CosmosDBGremlinDatabaseThroughputUpdate[put]
#--------------------------------------------------------------------------
BODY = {
"location": AZURE_LOCATION,
"resource": {
"throughput": "400"
}
}
result = self.mgmt_client.gremlin_resources.begin_update_gremlin_database_throughput(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, update_throughput_parameters=BODY)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/put/CosmosDBGremlinGraphThroughputUpdate[put]
#--------------------------------------------------------------------------
BODY = {
"location": AZURE_LOCATION,
"resource": {
"throughput": "400"
}
}
result = self.mgmt_client.gremlin_resources.begin_update_gremlin_graph_throughput(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME, update_throughput_parameters=BODY)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/get/CosmosDBGremlinGraphThroughputGet[get]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.get_gremlin_graph_throughput(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME)
#--------------------------------------------------------------------------
# /GremlinResources/get/CosmosDBGremlinDatabaseThroughputGet[get]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.get_gremlin_database_throughput(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME)
#--------------------------------------------------------------------------
# /GremlinResources/get/CosmosDBGremlinGraphGet[get]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.get_gremlin_graph(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME)
#--------------------------------------------------------------------------
# /GremlinResources/get/CosmosDBGremlinGraphList[get]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.list_gremlin_graphs(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME)
#--------------------------------------------------------------------------
# /GremlinResources/get/CosmosDBGremlinDatabaseGet[get]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.get_gremlin_database(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME)
#--------------------------------------------------------------------------
# /GremlinResources/get/CosmosDBGremlinDatabaseList[get]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.list_gremlin_databases(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME)
#--------------------------------------------------------------------------
# /GremlinResources/post/CosmosDBGremlinGraphMigrateToAutoscale[post]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.begin_migrate_gremlin_graph_to_autoscale(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/post/CosmosDBGremlinGraphMigrateToManualThroughput[post]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.begin_migrate_gremlin_graph_to_manual_throughput(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/post/CosmosDBGremlinDatabaseMigrateToAutoscale[post]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.begin_migrate_gremlin_database_to_autoscale(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/post/CosmosDBGremlinDatabaseMigrateToManualThroughput[post]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.begin_migrate_gremlin_database_to_manual_throughput(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/delete/CosmosDBGremlinGraphDelete[delete]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.begin_delete_gremlin_graph(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME, graph_name=GRAPH_NAME)
result = result.result()
#--------------------------------------------------------------------------
# /GremlinResources/delete/CosmosDBGremlinDatabaseDelete[delete]
#--------------------------------------------------------------------------
result = self.mgmt_client.gremlin_resources.begin_delete_gremlin_database(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME, database_name=DATABASE_NAME)
result = result.result()
#--------------------------------------------------------------------------
# /DatabaseAccounts/delete/CosmosDBDatabaseAccountDelete[delete]
#--------------------------------------------------------------------------
result = self.mgmt_client.database_accounts.begin_delete(resource_group_name=RESOURCE_GROUP, account_name=ACCOUNT_NAME)
result = result.result()
|