Edits history of script submission #24108 for ' Get system status (fortigate)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get system status
     * Get basic system status of the FortiGate (monitor API system/status), including the serial number, FortiOS version and build. Leave vdom empty for the management VDOM.
     */
    export async function main(auth: RT.Fortigate, vdom: string | undefined) {
      const url = new URL(
        `${auth.base_url.replace(/\/+$/, "")}/api/v2/monitor/system/status`
      )
      if (vdom != null && vdom !== "") {
        url.searchParams.append("vdom", vdom)
      }
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago