mirror of
https://github.com/tailscale/tailscale.git
synced 2026-07-29 16:56:32 -04:00
The client/local package doc said its API is not necessarily stable, but that caveat was easy to miss and only a few cert methods said anything explicit either way. People have been surprised by IPN bus changes between releases. Add explicit "API maturity" notes, matching the existing wording on the cert methods, marking stable: BugReport, BugReportWithOpts, CertDomains, CheckUpdate, CurrentDERPMap, DialTCP, UserDial, DisconnectControl, GetPrefs, EditPrefs, Status, StatusWithoutPeers, SetUseExitNode, SwitchProfile, UserProfile, and the WhoIs* methods. Mark unstable: ipn.Notify, WatchIPNBus, DoLocalRequest, the Debug*, Drive*, Check*, EventBus*, and Stream* methods, SetComponentDebugLogging, TailDaemonLogs, ShutdownTailscaled, GetDNSOSConfig, GetEffectivePolicy, GetServeConfig, and GetAppConnectorRouteInfo. Also note on tailcfg.DERPMap that the type is subject to minor changes over time though its general shape is stable, document that ipn.Prefs.CorpDNS is the internal name for "tailscale set --accept-dns", and add a package doc paragraph to client/local saying that methods without an explicit API maturity note should be assumed unstable. Updates #20406 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: I9333c58ae312e392c61d7de77987282e84ce2aeb
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build !ts_omit_syspolicy
|
|
|
|
package local
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"tailscale.com/util/syspolicy/setting"
|
|
)
|
|
|
|
// GetEffectivePolicy returns the effective policy for the specified scope.
|
|
//
|
|
// API maturity: this method is not considered a stable API and is
|
|
// subject to change between releases.
|
|
func (lc *Client) GetEffectivePolicy(ctx context.Context, scope setting.PolicyScope) (*setting.Snapshot, error) {
|
|
scopeID, err := scope.MarshalText()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
body, err := lc.get200(ctx, "/localapi/v0/policy/"+string(scopeID))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return decodeJSON[*setting.Snapshot](body)
|
|
}
|
|
|
|
// ReloadEffectivePolicy reloads the effective policy for the specified scope
|
|
// by reading and merging policy settings from all applicable policy sources.
|
|
func (lc *Client) ReloadEffectivePolicy(ctx context.Context, scope setting.PolicyScope) (*setting.Snapshot, error) {
|
|
scopeID, err := scope.MarshalText()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
body, err := lc.send(ctx, "POST", "/localapi/v0/policy/"+string(scopeID), 200, http.NoBody)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return decodeJSON[*setting.Snapshot](body)
|
|
}
|