github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/api/handlers/libpod/swagger.go (about) 1 package libpod 2 3 import ( 4 "net/http" 5 "os" 6 7 "github.com/containers/image/v5/manifest" 8 "github.com/containers/podman/v2/libpod/define" 9 "github.com/containers/podman/v2/pkg/api/handlers/utils" 10 "github.com/containers/podman/v2/pkg/domain/entities" 11 "github.com/pkg/errors" 12 ) 13 14 // DefaultPodmanSwaggerSpec provides the default path to the podman swagger spec file 15 const DefaultPodmanSwaggerSpec = "/usr/share/containers/podman/swagger.yaml" 16 17 // List Containers 18 // swagger:response ListContainers 19 type swagInspectPodResponse struct { 20 // in:body 21 Body []entities.ListContainer 22 } 23 24 // Inspect Manifest 25 // swagger:response InspectManifest 26 type swagInspectManifestResponse struct { 27 // in:body 28 Body manifest.List 29 } 30 31 // Kill Pod 32 // swagger:response PodKillReport 33 type swagKillPodResponse struct { 34 // in:body 35 Body entities.PodKillReport 36 } 37 38 // Pause pod 39 // swagger:response PodPauseReport 40 type swagPausePodResponse struct { 41 // in:body 42 Body entities.PodPauseReport 43 } 44 45 // Unpause pod 46 // swagger:response PodUnpauseReport 47 type swagUnpausePodResponse struct { 48 // in:body 49 Body entities.PodUnpauseReport 50 } 51 52 // Stop pod 53 // swagger:response PodStopReport 54 type swagStopPodResponse struct { 55 // in:body 56 Body entities.PodStopReport 57 } 58 59 // Restart pod 60 // swagger:response PodRestartReport 61 type swagRestartPodResponse struct { 62 // in:body 63 Body entities.PodRestartReport 64 } 65 66 // Start pod 67 // swagger:response PodStartReport 68 type swagStartPodResponse struct { 69 // in:body 70 Body entities.PodStartReport 71 } 72 73 // Prune pod 74 // swagger:response PodPruneReport 75 type swagPrunePodResponse struct { 76 // in:body 77 Body entities.PodPruneReport 78 } 79 80 // Rm pod 81 // swagger:response PodRmReport 82 type swagRmPodResponse struct { 83 // in:body 84 Body entities.PodRmReport 85 } 86 87 // Info 88 // swagger:response InfoResponse 89 type swagInfoResponse struct { 90 // in:body 91 Body define.Info 92 } 93 94 // Network rm 95 // swagger:response NetworkRmReport 96 type swagNetworkRmReport struct { 97 // in:body 98 Body entities.NetworkRmReport 99 } 100 101 // Network inspect 102 // swagger:response NetworkInspectReport 103 type swagNetworkInspectReport struct { 104 // in:body 105 Body []entities.NetworkInspectReport 106 } 107 108 // Network list 109 // swagger:response NetworkListReport 110 type swagNetworkListReport struct { 111 // in:body 112 Body []entities.NetworkListReport 113 } 114 115 // Network create 116 // swagger:response NetworkCreateReport 117 type swagNetworkCreateReport struct { 118 // in:body 119 Body entities.NetworkCreateReport 120 } 121 122 func ServeSwagger(w http.ResponseWriter, r *http.Request) { 123 path := DefaultPodmanSwaggerSpec 124 if p, found := os.LookupEnv("PODMAN_SWAGGER_SPEC"); found { 125 path = p 126 } 127 if _, err := os.Stat(path); err != nil { 128 if os.IsNotExist(err) { 129 utils.InternalServerError(w, errors.Errorf("file %q does not exist", path)) 130 return 131 } 132 utils.InternalServerError(w, err) 133 return 134 } 135 w.Header().Set("Content-Type", "text/yaml") 136 http.ServeFile(w, r, path) 137 }