github.com/opentofu/opentofu@v1.7.1/internal/registry/response/module.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package response 7 8 import ( 9 "time" 10 ) 11 12 // Module is the response structure with the data for a single module version. 13 type Module struct { 14 ID string `json:"id"` 15 16 //--------------------------------------------------------------- 17 // Metadata about the overall module. 18 19 Owner string `json:"owner"` 20 Namespace string `json:"namespace"` 21 Name string `json:"name"` 22 Version string `json:"version"` 23 Provider string `json:"provider"` 24 Description string `json:"description"` 25 Source string `json:"source"` 26 PublishedAt time.Time `json:"published_at"` 27 Downloads int `json:"downloads"` 28 Verified bool `json:"verified"` 29 } 30 31 // ModuleDetail represents a module in full detail. 32 type ModuleDetail struct { 33 Module 34 35 //--------------------------------------------------------------- 36 // Metadata about the overall module. This is only available when 37 // requesting the specific module (not in list responses). 38 39 // Root is the root module. 40 Root *ModuleSubmodule `json:"root"` 41 42 // Submodules are the other submodules that are available within 43 // this module. 44 Submodules []*ModuleSubmodule `json:"submodules"` 45 46 //--------------------------------------------------------------- 47 // The fields below are only set when requesting this specific 48 // module. They are available to easily know all available versions 49 // and providers without multiple API calls. 50 51 Providers []string `json:"providers"` // All available providers 52 Versions []string `json:"versions"` // All versions 53 } 54 55 // ModuleSubmodule is the metadata about a specific submodule within 56 // a module. This includes the root module as a special case. 57 type ModuleSubmodule struct { 58 Path string `json:"path"` 59 Readme string `json:"readme"` 60 Empty bool `json:"empty"` 61 62 Inputs []*ModuleInput `json:"inputs"` 63 Outputs []*ModuleOutput `json:"outputs"` 64 Dependencies []*ModuleDep `json:"dependencies"` 65 Resources []*ModuleResource `json:"resources"` 66 } 67 68 // ModuleInput is an input for a module. 69 type ModuleInput struct { 70 Name string `json:"name"` 71 Description string `json:"description"` 72 Default string `json:"default"` 73 } 74 75 // ModuleOutput is an output for a module. 76 type ModuleOutput struct { 77 Name string `json:"name"` 78 Description string `json:"description"` 79 } 80 81 // ModuleDep is an output for a module. 82 type ModuleDep struct { 83 Name string `json:"name"` 84 Source string `json:"source"` 85 Version string `json:"version"` 86 } 87 88 // ModuleProviderDep is the output for a provider dependency 89 type ModuleProviderDep struct { 90 Name string `json:"name"` 91 Version string `json:"version"` 92 } 93 94 // ModuleResource is an output for a module. 95 type ModuleResource struct { 96 Name string `json:"name"` 97 Type string `json:"type"` 98 }