@@ -73,13 +73,16 @@ func GetCosmosDBAccountContextE(ctx context.Context, subscriptionID string, reso
7373 return nil , err
7474 }
7575
76- // Get the corresponding database account
77- resp , err := cosmosClient .Get (ctx , resourceGroupName , accountName , nil )
76+ return GetCosmosDBAccountWithClient (ctx , cosmosClient , resourceGroupName , accountName )
77+ }
78+
79+ // GetCosmosDBAccountWithClient gets a database account using the provided DatabaseAccountsClient.
80+ func GetCosmosDBAccountWithClient (ctx context.Context , client * armcosmos.DatabaseAccountsClient , resourceGroupName string , accountName string ) (* armcosmos.DatabaseAccountGetResults , error ) {
81+ resp , err := client .Get (ctx , resourceGroupName , accountName , nil )
7882 if err != nil {
7983 return nil , err
8084 }
8185
82- // Return DB
8386 return & resp .DatabaseAccountGetResults , nil
8487}
8588
@@ -148,13 +151,16 @@ func GetCosmosDBSQLDatabaseContextE(ctx context.Context, subscriptionID string,
148151 return nil , err
149152 }
150153
151- // Get the corresponding database
152- resp , err := cosmosClient .GetSQLDatabase (ctx , resourceGroupName , accountName , databaseName , nil )
154+ return GetCosmosDBSQLDatabaseWithClient (ctx , cosmosClient , resourceGroupName , accountName , databaseName )
155+ }
156+
157+ // GetCosmosDBSQLDatabaseWithClient gets a SQL database using the provided SQLResourcesClient.
158+ func GetCosmosDBSQLDatabaseWithClient (ctx context.Context , client * armcosmos.SQLResourcesClient , resourceGroupName string , accountName string , databaseName string ) (* armcosmos.SQLDatabaseGetResults , error ) {
159+ resp , err := client .GetSQLDatabase (ctx , resourceGroupName , accountName , databaseName , nil )
153160 if err != nil {
154161 return nil , err
155162 }
156163
157- // Return DB
158164 return & resp .SQLDatabaseGetResults , nil
159165}
160166
@@ -192,13 +198,16 @@ func GetCosmosDBSQLContainerContextE(ctx context.Context, subscriptionID string,
192198 return nil , err
193199 }
194200
195- // Get the corresponding SQL container
196- resp , err := cosmosClient .GetSQLContainer (ctx , resourceGroupName , accountName , databaseName , containerName , nil )
201+ return GetCosmosDBSQLContainerWithClient (ctx , cosmosClient , resourceGroupName , accountName , databaseName , containerName )
202+ }
203+
204+ // GetCosmosDBSQLContainerWithClient gets a SQL container using the provided SQLResourcesClient.
205+ func GetCosmosDBSQLContainerWithClient (ctx context.Context , client * armcosmos.SQLResourcesClient , resourceGroupName string , accountName string , databaseName string , containerName string ) (* armcosmos.SQLContainerGetResults , error ) {
206+ resp , err := client .GetSQLContainer (ctx , resourceGroupName , accountName , databaseName , containerName , nil )
197207 if err != nil {
198208 return nil , err
199209 }
200210
201- // Return container
202211 return & resp .SQLContainerGetResults , nil
203212}
204213
@@ -236,13 +245,17 @@ func GetCosmosDBSQLDatabaseThroughputContextE(ctx context.Context, subscriptionI
236245 return nil , err
237246 }
238247
239- // Get the corresponding database throughput config
240- resp , err := cosmosClient .GetSQLDatabaseThroughput (ctx , resourceGroupName , accountName , databaseName , nil )
248+ return GetCosmosDBSQLDatabaseThroughputWithClient (ctx , cosmosClient , resourceGroupName , accountName , databaseName )
249+ }
250+
251+ // GetCosmosDBSQLDatabaseThroughputWithClient gets a SQL database throughput configuration
252+ // using the provided SQLResourcesClient.
253+ func GetCosmosDBSQLDatabaseThroughputWithClient (ctx context.Context , client * armcosmos.SQLResourcesClient , resourceGroupName string , accountName string , databaseName string ) (* armcosmos.ThroughputSettingsGetResults , error ) {
254+ resp , err := client .GetSQLDatabaseThroughput (ctx , resourceGroupName , accountName , databaseName , nil )
241255 if err != nil {
242256 return nil , err
243257 }
244258
245- // Return throughput config
246259 return & resp .ThroughputSettingsGetResults , nil
247260}
248261
@@ -280,12 +293,16 @@ func GetCosmosDBSQLContainerThroughputContextE(ctx context.Context, subscription
280293 return nil , err
281294 }
282295
283- // Get the corresponding container throughput config
284- resp , err := cosmosClient .GetSQLContainerThroughput (ctx , resourceGroupName , accountName , databaseName , containerName , nil )
296+ return GetCosmosDBSQLContainerThroughputWithClient (ctx , cosmosClient , resourceGroupName , accountName , databaseName , containerName )
297+ }
298+
299+ // GetCosmosDBSQLContainerThroughputWithClient gets a SQL container throughput configuration
300+ // using the provided SQLResourcesClient.
301+ func GetCosmosDBSQLContainerThroughputWithClient (ctx context.Context , client * armcosmos.SQLResourcesClient , resourceGroupName string , accountName string , databaseName string , containerName string ) (* armcosmos.ThroughputSettingsGetResults , error ) {
302+ resp , err := client .GetSQLContainerThroughput (ctx , resourceGroupName , accountName , databaseName , containerName , nil )
285303 if err != nil {
286304 return nil , err
287305 }
288306
289- // Return throughput config
290307 return & resp .ThroughputSettingsGetResults , nil
291308}
0 commit comments