github.com/stolowski/snapd@v0.0.0-20210407085831-115137ce5a22/client/console_conf.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2020 Canonical Ltd
     5   *
     6   * This program is free software: you can redistribute it and/or modify
     7   * it under the terms of the GNU General Public License version 3 as
     8   * published by the Free Software Foundation.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17   *
    18   */
    19  
    20  package client
    21  
    22  import "time"
    23  
    24  // InternalConsoleConfStartResponse is the response from console-conf start
    25  // support
    26  type InternalConsoleConfStartResponse struct {
    27  	ActiveAutoRefreshChanges []string `json:"active-auto-refreshes,omitempty"`
    28  	ActiveAutoRefreshSnaps   []string `json:"active-auto-refresh-snaps,omitempty"`
    29  }
    30  
    31  // InternalConsoleConfStart invokes the dedicated console-conf start support
    32  // to handle intervening auto-refreshes.
    33  // Not for general use.
    34  func (client *Client) InternalConsoleConfStart() ([]string, []string, error) {
    35  	resp := &InternalConsoleConfStartResponse{}
    36  	// do the post with a short timeout so that if snapd is not available due to
    37  	// maintenance we will return very quickly so the caller can handle that
    38  	opts := &doOptions{
    39  		Timeout: 2 * time.Second,
    40  		Retry:   1 * time.Hour,
    41  	}
    42  	_, err := client.doSyncWithOpts("POST", "/v2/internal/console-conf-start", nil, nil, nil, resp, opts)
    43  	return resp.ActiveAutoRefreshChanges, resp.ActiveAutoRefreshSnaps, err
    44  }