def __init__(self, api_server_url: str = None, refresh_token: str = None, debug: bool = False, log: logging.Logger = None) -> None: self._debug = debug self._log = log self._progress_callback = None self._access_token = None self._api_url = self._normalize_url(api_server_url or os.getenv('BANYAN_API_URL') or BanyanApiClient.DEFAULT_API_URL) self._refresh_token = refresh_token or os.getenv('BANYAN_REFRESH_TOKEN') if not self._refresh_token: raise BanyanError("Refresh token must be set") if self._debug: requests_log = logging.getLogger('requests.packages.urllib3') requests_log.setLevel(logging.DEBUG) requests_log.propagate = True self._http = self._create_session() self._services = ServiceAPI(self) self._policies = PolicyAPI(self) self._attach = AttachmentAPI(self) self._roles = RoleAPI(self) self._shields = ShieldAPI(self) self._agents = NetagentAPI(self) self._users = UserAPI(self) self._devices = DeviceAPI(self) self._events = EventV2API(self) self._audit = AuditAPI(self)
def detach(self, service: ServiceInfoOrName, policy: PolicyInfoOrName) -> str: from banyan.api.policy import PolicyAPI return PolicyAPI(self._client).detach(policy, service)
def attach(self, service: ServiceInfoOrName, policy: PolicyInfoOrName, enforcing: bool) -> PolicyAttachInfo: from banyan.api.policy import PolicyAPI return PolicyAPI(self._client).attach(policy, service, enforcing)