@@ -33,6 +33,8 @@ func newAgents(rootSDK *CipherSwarmAgentSDK, sdkConfig config.SDKConfiguration,
3333
3434// GetAgent - Gets an instance of an agent
3535// Returns an agent
36+ //
37+ // If set, this operation will use [Security.BearerAuth] from the global security.
3638func (s * Agents ) GetAgent (ctx context.Context , id int64 , opts ... operations.Option ) (* operations.GetAgentResponse , error ) {
3739 request := operations.GetAgentRequest {
3840 ID : id ,
@@ -88,7 +90,7 @@ func (s *Agents) GetAgent(ctx context.Context, id int64, opts ...operations.Opti
8890 req .Header .Set ("Accept" , "application/json" )
8991 req .Header .Set ("User-Agent" , s .sdkConfiguration .UserAgent )
9092
91- if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
93+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security , "BearerAuth" ); err != nil {
9294 return nil , err
9395 }
9496
@@ -179,7 +181,7 @@ func (s *Agents) GetAgent(ctx context.Context, id int64, opts ...operations.Opti
179181
180182 _ , err = s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
181183 return nil , err
182- } else if utils .MatchStatusCodes ([]string {"401" , " 4XX" , "5XX" }, httpRes .StatusCode ) {
184+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
183185 _httpRes , err := s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
184186 if err != nil {
185187 return nil , err
@@ -269,10 +271,12 @@ func (s *Agents) GetAgent(ctx context.Context, id int64, opts ...operations.Opti
269271
270272// UpdateAgent - Updates the agent
271273// Updates an agent
272- func (s * Agents ) UpdateAgent (ctx context.Context , id int64 , requestBody operations.UpdateAgentRequestBody , opts ... operations.Option ) (* operations.UpdateAgentResponse , error ) {
274+ //
275+ // If set, this operation will use [Security.BearerAuth] from the global security.
276+ func (s * Agents ) UpdateAgent (ctx context.Context , id int64 , updateAgentRequest components.UpdateAgentRequest , opts ... operations.Option ) (* operations.UpdateAgentResponse , error ) {
273277 request := operations.UpdateAgentRequest {
274- ID : id ,
275- RequestBody : requestBody ,
278+ ID : id ,
279+ UpdateAgentRequest : updateAgentRequest ,
276280 }
277281
278282 o := operations.Options {}
@@ -306,7 +310,7 @@ func (s *Agents) UpdateAgent(ctx context.Context, id int64, requestBody operatio
306310 OperationID : "updateAgent" ,
307311 SecuritySource : s .sdkConfiguration .Security ,
308312 }
309- bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , false , "RequestBody " , "json" , `request:"mediaType=application/json"` )
313+ bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , false , "UpdateAgentRequest " , "json" , `request:"mediaType=application/json"` )
310314 if err != nil {
311315 return nil , err
312316 }
@@ -332,7 +336,7 @@ func (s *Agents) UpdateAgent(ctx context.Context, id int64, requestBody operatio
332336 req .Header .Set ("Content-Type" , reqContentType )
333337 }
334338
335- if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
339+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security , "BearerAuth" ); err != nil {
336340 return nil , err
337341 }
338342
@@ -423,7 +427,7 @@ func (s *Agents) UpdateAgent(ctx context.Context, id int64, requestBody operatio
423427
424428 _ , err = s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
425429 return nil , err
426- } else if utils .MatchStatusCodes ([]string {"401" , " 4XX" , "5XX" }, httpRes .StatusCode ) {
430+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
427431 _httpRes , err := s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
428432 if err != nil {
429433 return nil , err
@@ -513,10 +517,12 @@ func (s *Agents) UpdateAgent(ctx context.Context, id int64, requestBody operatio
513517
514518// SendHeartbeat - Send a heartbeat for an agent
515519// Send a heartbeat for an agent to keep it alive. Optionally accepts an 'activity' parameter in the request body to track the agent's current activity state.
516- func (s * Agents ) SendHeartbeat (ctx context.Context , id int64 , requestBody * operations.SendHeartbeatRequestBody , opts ... operations.Option ) (* operations.SendHeartbeatResponse , error ) {
520+ //
521+ // If set, this operation will use [Security.BearerAuth] from the global security.
522+ func (s * Agents ) SendHeartbeat (ctx context.Context , id int64 , agentHeartbeatRequest * components.AgentHeartbeatRequest , opts ... operations.Option ) (* operations.SendHeartbeatResponse , error ) {
517523 request := operations.SendHeartbeatRequest {
518- ID : id ,
519- RequestBody : requestBody ,
524+ ID : id ,
525+ AgentHeartbeatRequest : agentHeartbeatRequest ,
520526 }
521527
522528 o := operations.Options {}
@@ -550,7 +556,7 @@ func (s *Agents) SendHeartbeat(ctx context.Context, id int64, requestBody *opera
550556 OperationID : "sendHeartbeat" ,
551557 SecuritySource : s .sdkConfiguration .Security ,
552558 }
553- bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , true , "RequestBody " , "json" , `request:"mediaType=application/json"` )
559+ bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , true , "AgentHeartbeatRequest " , "json" , `request:"mediaType=application/json"` )
554560 if err != nil {
555561 return nil , err
556562 }
@@ -576,7 +582,7 @@ func (s *Agents) SendHeartbeat(ctx context.Context, id int64, requestBody *opera
576582 req .Header .Set ("Content-Type" , reqContentType )
577583 }
578584
579- if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
585+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security , "BearerAuth" ); err != nil {
580586 return nil , err
581587 }
582588
@@ -667,7 +673,7 @@ func (s *Agents) SendHeartbeat(ctx context.Context, id int64, requestBody *opera
667673
668674 _ , err = s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
669675 return nil , err
670- } else if utils .MatchStatusCodes ([]string {"401" , " 4XX" , "5XX" }, httpRes .StatusCode ) {
676+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
671677 _httpRes , err := s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
672678 if err != nil {
673679 return nil , err
@@ -697,12 +703,12 @@ func (s *Agents) SendHeartbeat(ctx context.Context, id int64, requestBody *opera
697703 return nil , err
698704 }
699705
700- var out operations. SendHeartbeatResponseBody
706+ var out components. HeartbeatResponse
701707 if err := utils .UnmarshalJsonFromResponseBody (bytes .NewBuffer (rawBody ), & out , "" ); err != nil {
702708 return nil , err
703709 }
704710
705- res .Object = & out
711+ res .HeartbeatResponse = & out
706712 default :
707713 rawBody , err := utils .ConsumeRawBody (httpRes )
708714 if err != nil {
@@ -759,10 +765,12 @@ func (s *Agents) SendHeartbeat(ctx context.Context, id int64, requestBody *opera
759765
760766// SubmitBenchmark - submit agent benchmarks
761767// Submit a benchmark for an agent
762- func (s * Agents ) SubmitBenchmark (ctx context.Context , id int64 , requestBody operations.SubmitBenchmarkRequestBody , opts ... operations.Option ) (* operations.SubmitBenchmarkResponse , error ) {
768+ //
769+ // If set, this operation will use [Security.BearerAuth] from the global security.
770+ func (s * Agents ) SubmitBenchmark (ctx context.Context , id int64 , submitBenchmarkRequest components.SubmitBenchmarkRequest , opts ... operations.Option ) (* operations.SubmitBenchmarkResponse , error ) {
763771 request := operations.SubmitBenchmarkRequest {
764- ID : id ,
765- RequestBody : requestBody ,
772+ ID : id ,
773+ SubmitBenchmarkRequest : submitBenchmarkRequest ,
766774 }
767775
768776 o := operations.Options {}
@@ -796,7 +804,7 @@ func (s *Agents) SubmitBenchmark(ctx context.Context, id int64, requestBody oper
796804 OperationID : "submitBenchmark" ,
797805 SecuritySource : s .sdkConfiguration .Security ,
798806 }
799- bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , false , "RequestBody " , "json" , `request:"mediaType=application/json"` )
807+ bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , false , "SubmitBenchmarkRequest " , "json" , `request:"mediaType=application/json"` )
800808 if err != nil {
801809 return nil , err
802810 }
@@ -822,7 +830,7 @@ func (s *Agents) SubmitBenchmark(ctx context.Context, id int64, requestBody oper
822830 req .Header .Set ("Content-Type" , reqContentType )
823831 }
824832
825- if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
833+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security , "BearerAuth" ); err != nil {
826834 return nil , err
827835 }
828836
@@ -913,7 +921,7 @@ func (s *Agents) SubmitBenchmark(ctx context.Context, id int64, requestBody oper
913921
914922 _ , err = s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
915923 return nil , err
916- } else if utils .MatchStatusCodes ([]string {"400" , "401" , "422" , " 4XX" , "5XX" }, httpRes .StatusCode ) {
924+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
917925 _httpRes , err := s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
918926 if err != nil {
919927 return nil , err
@@ -935,8 +943,27 @@ func (s *Agents) SubmitBenchmark(ctx context.Context, id int64, requestBody oper
935943 }
936944
937945 switch {
938- case httpRes .StatusCode == 204 :
939- utils .DrainBody (httpRes )
946+ case httpRes .StatusCode == 200 :
947+ switch {
948+ case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/json` ):
949+ rawBody , err := utils .ConsumeRawBody (httpRes )
950+ if err != nil {
951+ return nil , err
952+ }
953+
954+ var out components.BenchmarkReceipt
955+ if err := utils .UnmarshalJsonFromResponseBody (bytes .NewBuffer (rawBody ), & out , "" ); err != nil {
956+ return nil , err
957+ }
958+
959+ res .BenchmarkReceipt = & out
960+ default :
961+ rawBody , err := utils .ConsumeRawBody (httpRes )
962+ if err != nil {
963+ return nil , err
964+ }
965+ return nil , sdkerrors .NewSDKError (fmt .Sprintf ("unknown content-type received: %s" , httpRes .Header .Get ("Content-Type" )), httpRes .StatusCode , string (rawBody ), httpRes )
966+ }
940967 case httpRes .StatusCode == 400 :
941968 fallthrough
942969 case httpRes .StatusCode == 401 :
@@ -988,10 +1015,12 @@ func (s *Agents) SubmitBenchmark(ctx context.Context, id int64, requestBody oper
9881015
9891016// SubmitErrorAgent - Submit an error for an agent
9901017// Submit an error for an agent
991- func (s * Agents ) SubmitErrorAgent (ctx context.Context , id int64 , requestBody operations.SubmitErrorAgentRequestBody , opts ... operations.Option ) (* operations.SubmitErrorAgentResponse , error ) {
1018+ //
1019+ // If set, this operation will use [Security.BearerAuth] from the global security.
1020+ func (s * Agents ) SubmitErrorAgent (ctx context.Context , id int64 , submitErrorRequest components.SubmitErrorRequest , opts ... operations.Option ) (* operations.SubmitErrorAgentResponse , error ) {
9921021 request := operations.SubmitErrorAgentRequest {
993- ID : id ,
994- RequestBody : requestBody ,
1022+ ID : id ,
1023+ SubmitErrorRequest : submitErrorRequest ,
9951024 }
9961025
9971026 o := operations.Options {}
@@ -1025,7 +1054,7 @@ func (s *Agents) SubmitErrorAgent(ctx context.Context, id int64, requestBody ope
10251054 OperationID : "submitErrorAgent" ,
10261055 SecuritySource : s .sdkConfiguration .Security ,
10271056 }
1028- bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , false , "RequestBody " , "json" , `request:"mediaType=application/json"` )
1057+ bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , false , "SubmitErrorRequest " , "json" , `request:"mediaType=application/json"` )
10291058 if err != nil {
10301059 return nil , err
10311060 }
@@ -1051,7 +1080,7 @@ func (s *Agents) SubmitErrorAgent(ctx context.Context, id int64, requestBody ope
10511080 req .Header .Set ("Content-Type" , reqContentType )
10521081 }
10531082
1054- if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
1083+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security , "BearerAuth" ); err != nil {
10551084 return nil , err
10561085 }
10571086
@@ -1142,7 +1171,7 @@ func (s *Agents) SubmitErrorAgent(ctx context.Context, id int64, requestBody ope
11421171
11431172 _ , err = s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
11441173 return nil , err
1145- } else if utils .MatchStatusCodes ([]string {"401" , " 4XX" , "5XX" }, httpRes .StatusCode ) {
1174+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
11461175 _httpRes , err := s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
11471176 if err != nil {
11481177 return nil , err
@@ -1213,6 +1242,8 @@ func (s *Agents) SubmitErrorAgent(ctx context.Context, id int64, requestBody ope
12131242
12141243// SetAgentShutdown - shutdown agent
12151244// Marks the agent as shutdown and offline, freeing any assigned tasks.
1245+ //
1246+ // If set, this operation will use [Security.BearerAuth] from the global security.
12161247func (s * Agents ) SetAgentShutdown (ctx context.Context , id int64 , opts ... operations.Option ) (* operations.SetAgentShutdownResponse , error ) {
12171248 request := operations.SetAgentShutdownRequest {
12181249 ID : id ,
@@ -1268,7 +1299,7 @@ func (s *Agents) SetAgentShutdown(ctx context.Context, id int64, opts ...operati
12681299 req .Header .Set ("Accept" , "application/json" )
12691300 req .Header .Set ("User-Agent" , s .sdkConfiguration .UserAgent )
12701301
1271- if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
1302+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security , "BearerAuth" ); err != nil {
12721303 return nil , err
12731304 }
12741305
@@ -1359,7 +1390,7 @@ func (s *Agents) SetAgentShutdown(ctx context.Context, id int64, opts ...operati
13591390
13601391 _ , err = s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
13611392 return nil , err
1362- } else if utils .MatchStatusCodes ([]string {"401" , " 4XX" , "5XX" }, httpRes .StatusCode ) {
1393+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
13631394 _httpRes , err := s .hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
13641395 if err != nil {
13651396 return nil , err
0 commit comments