MCPcopy
hub / github.com/lxc/incus / networkIntegrationPost

Function networkIntegrationPost

cmd/incusd/network_integrations.go:832–878  ·  view source on GitHub ↗

swagger:operation POST /1.0/network-integrations/{integration} network-integrations network_integration_post Rename the network integration Renames the network integration. --- produces: - application/json parameters: - in: path name: integration description: Integration name

(d *Daemon, r *http.Request)

Source from the content-addressed store, hash-verified

830// "500":
831// $ref: "#/responses/InternalServerError"
832func networkIntegrationPost(d *Daemon, r *http.Request) response.Response {
833 s := d.State()
834
835 // Get the integration name.
836 integrationName, err := pathVar(r, "integration")
837 if err != nil {
838 return response.SmartError(err)
839 }
840
841 // Decode the request.
842 req := api.NetworkIntegrationPost{}
843
844 err = json.NewDecoder(r.Body).Decode(&req)
845 if err != nil {
846 return response.BadRequest(err)
847 }
848
849 // Quick checks.
850 err = validate.IsAPIName(req.Name, false)
851 if err != nil {
852 return response.BadRequest(fmt.Errorf("Invalid network integration name: %w", err))
853 }
854
855 // Rename the DB record.
856 err = s.DB.Cluster.Transaction(r.Context(), func(ctx context.Context, tx *db.ClusterTx) error {
857 err := dbCluster.RenameNetworkIntegration(ctx, tx.Tx(), integrationName, req.Name)
858 if err != nil {
859 return err
860 }
861
862 return nil
863 })
864 if err != nil {
865 return response.SmartError(err)
866 }
867
868 // Rename the integration in the auth backend.
869 err = s.Authorizer.RenameNetworkIntegration(r.Context(), integrationName, req.Name)
870 if err != nil {
871 logger.Error("Failed to remove network integration from authorizer", logger.Ctx{"name": integrationName, "error": err})
872 }
873
874 // Emit the lifecycle event.
875 s.Events.SendLifecycle(api.ProjectDefaultName, lifecycle.NetworkIntegrationDeleted.Event(req.Name, request.CreateRequestor(r), logger.Ctx{"old_name": integrationName}))
876
877 return response.EmptySyncResponse
878}
879
880// networkIntegrationValidate validates the configuration keys/values for network integration.
881func networkIntegrationValidate(integrationType string, inUse bool, oldConfig map[string]string, config map[string]string) error {

Callers

nothing calls this directly

Calls 14

SmartErrorFunction · 0.92
BadRequestFunction · 0.92
IsAPINameFunction · 0.92
ErrorFunction · 0.92
CreateRequestorFunction · 0.92
pathVarFunction · 0.85
ErrorfMethod · 0.80
ContextMethod · 0.80
TxMethod · 0.80
SendLifecycleMethod · 0.80
StateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…