@@ -992,46 +992,6 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
992
992
}
993
993
}
994
994
995
- // Set query api endpoints
996
- if ! plan .QueryAPIEndpoints .IsNull () {
997
- qae := models.QueryAPIEndpoints {}
998
- diag := plan .QueryAPIEndpoints .As (ctx , & qae , basetypes.ObjectAsOptions {
999
- UnhandledNullAsEmpty : false ,
1000
- UnhandledUnknownAsEmpty : false ,
1001
- })
1002
- if diag .HasError () {
1003
- resp .Diagnostics .Append (diag .Errors ()... )
1004
- return
1005
- }
1006
-
1007
- roles := make ([]string , 0 )
1008
- diag = qae .Roles .ElementsAs (ctx , & roles , false )
1009
- if diag .HasError () {
1010
- resp .Diagnostics .Append (diag .Errors ()... )
1011
- return
1012
- }
1013
-
1014
- keys := make ([]string , 0 )
1015
- diag = qae .APIKeyIDs .ElementsAs (ctx , & keys , false )
1016
- if diag .HasError () {
1017
- resp .Diagnostics .Append (diag .Errors ()... )
1018
- return
1019
- }
1020
-
1021
- _ , err := r .client .CreateQueryEndpoint (ctx , s .Id , api.ServiceQueryEndpoint {
1022
- Roles : roles ,
1023
- OpenApiKeys : keys ,
1024
- AllowedOrigins : qae .AllowedOrigins .ValueString (),
1025
- })
1026
- if err != nil {
1027
- resp .Diagnostics .AddError (
1028
- "Error setting service query API endpoints" ,
1029
- "Could not set service query API endpoints, unexpected error: " + err .Error (),
1030
- )
1031
- return
1032
- }
1033
- }
1034
-
1035
995
// Set backup settings.
1036
996
if ! plan .BackupConfiguration .IsNull () && ! plan .BackupConfiguration .IsUnknown () {
1037
997
bc := models.BackupConfiguration {}
@@ -1063,6 +1023,46 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
1063
1023
}
1064
1024
}
1065
1025
1026
+ // Set query api endpoints
1027
+ if ! plan .QueryAPIEndpoints .IsNull () {
1028
+ qae := models.QueryAPIEndpoints {}
1029
+ diag := plan .QueryAPIEndpoints .As (ctx , & qae , basetypes.ObjectAsOptions {
1030
+ UnhandledNullAsEmpty : false ,
1031
+ UnhandledUnknownAsEmpty : false ,
1032
+ })
1033
+ if diag .HasError () {
1034
+ resp .Diagnostics .Append (diag .Errors ()... )
1035
+ return
1036
+ }
1037
+
1038
+ roles := make ([]string , 0 )
1039
+ diag = qae .Roles .ElementsAs (ctx , & roles , false )
1040
+ if diag .HasError () {
1041
+ resp .Diagnostics .Append (diag .Errors ()... )
1042
+ return
1043
+ }
1044
+
1045
+ keys := make ([]string , 0 )
1046
+ diag = qae .APIKeyIDs .ElementsAs (ctx , & keys , false )
1047
+ if diag .HasError () {
1048
+ resp .Diagnostics .Append (diag .Errors ()... )
1049
+ return
1050
+ }
1051
+
1052
+ _ , err := r .client .CreateQueryEndpoint (ctx , s .Id , api.ServiceQueryEndpoint {
1053
+ Roles : roles ,
1054
+ OpenApiKeys : keys ,
1055
+ AllowedOrigins : qae .AllowedOrigins .ValueString (),
1056
+ })
1057
+ if err != nil {
1058
+ resp .Diagnostics .AddError (
1059
+ "Error setting service query API endpoints" ,
1060
+ "Could not set service query API endpoints, unexpected error: " + err .Error (),
1061
+ )
1062
+ return
1063
+ }
1064
+ }
1065
+
1066
1066
// Map response body to schema and populate Computed attribute values
1067
1067
plan .ID = types .StringValue (s .Id )
1068
1068
err = r .syncServiceState (ctx , & plan , true )
0 commit comments