Skip to content

Commit

Permalink
refactor: construct params in a way to satisfy generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Oct 8, 2024
1 parent bd503a9 commit d73952a
Showing 1 changed file with 140 additions and 62 deletions.
202 changes: 140 additions & 62 deletions api_open_fga.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,13 +1086,17 @@ func (a *OpenFgaApiService) CheckExecute(r ApiCheckRequest) (CheckResponse, *_ne
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"Check",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -1359,12 +1363,17 @@ func (a *OpenFgaApiService) CreateStoreExecute(r ApiCreateStoreRequest) (CreateS
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"CreateStore",
map[string]interface{}{
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -1623,13 +1632,17 @@ func (a *OpenFgaApiService) DeleteStoreExecute(r ApiDeleteStoreRequest) (*_netht
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"DeleteStore",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -1962,13 +1975,17 @@ func (a *OpenFgaApiService) ExpandExecute(r ApiExpandRequest) (ExpandResponse, *
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"Expand",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -2238,13 +2255,17 @@ func (a *OpenFgaApiService) GetStoreExecute(r ApiGetStoreRequest) (GetStoreRespo
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"GetStore",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -2533,13 +2554,17 @@ func (a *OpenFgaApiService) ListObjectsExecute(r ApiListObjectsRequest) (ListObj
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ListObjects",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -2815,12 +2840,17 @@ func (a *OpenFgaApiService) ListStoresExecute(r ApiListStoresRequest) (ListStore
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ListStores",
map[string]interface{}{
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -3111,13 +3141,17 @@ func (a *OpenFgaApiService) ListUsersExecute(r ApiListUsersRequest) (ListUsersRe
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ListUsers",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -3509,13 +3543,17 @@ func (a *OpenFgaApiService) ReadExecute(r ApiReadRequest) (ReadResponse, *_netht
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"Read",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -3793,13 +3831,17 @@ func (a *OpenFgaApiService) ReadAssertionsExecute(r ApiReadAssertionsRequest) (R
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ReadAssertions",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -4120,13 +4162,17 @@ func (a *OpenFgaApiService) ReadAuthorizationModelExecute(r ApiReadAuthorization
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ReadAuthorizationModel",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -4454,13 +4500,17 @@ func (a *OpenFgaApiService) ReadAuthorizationModelsExecute(r ApiReadAuthorizatio
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ReadAuthorizationModels",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -4760,13 +4810,17 @@ func (a *OpenFgaApiService) ReadChangesExecute(r ApiReadChangesRequest) (ReadCha
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"ReadChanges",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -5089,13 +5143,17 @@ func (a *OpenFgaApiService) WriteExecute(r ApiWriteRequest) (map[string]interfac
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"Write",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -5373,13 +5431,17 @@ func (a *OpenFgaApiService) WriteAssertionsExecute(r ApiWriteAssertionsRequest)
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"WriteAssertions",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand Down Expand Up @@ -5704,13 +5766,17 @@ func (a *OpenFgaApiService) WriteAuthorizationModelExecute(r ApiWriteAuthorizati
}

metrics := telemetry.GetMetrics(telemetry.TelemetryFactoryParameters{Configuration: a.client.cfg.Telemetry})
params := map[string]interface{}{
"body": localVarPostBody,
}

if storeId := getStoreID(r); storeId != "" {
params["storeId"] = storeId
}

var attrs, queryDuration, requestDuration, _ = metrics.BuildTelemetryAttributes(
"WriteAuthorizationModel",
map[string]interface{}{
"storeId": r.storeId,
"body": localVarPostBody,
},
params,
req,
localVarHTTPResponse,
requestStarted,
Expand All @@ -5731,3 +5797,15 @@ func (a *OpenFgaApiService) WriteAuthorizationModelExecute(r ApiWriteAuthorizati
var localVarReturnValue WriteAuthorizationModelResponse
return localVarReturnValue, nil, reportError("Error not handled properly")
}

type withStoreId struct {
storeId string
}

func getStoreID(i interface{}) string {
if r, ok := i.(withStoreId); ok {
return r.storeId
}

return ""
}

0 comments on commit d73952a

Please sign in to comment.