objc2-open-directory 0.3.2

Bindings to the OpenDirectory framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-security-foundation")]
use objc2_security_foundation::*;

use crate::*;

extern "C" {
    /// the address to connect to via proxy, used when making the options dictionary
    ///
    /// the address to connect to via proxy, used when making the options dictionary
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odsessionproxyaddress?language=objc)
    pub static ODSessionProxyAddress: Option<&'static NSString>;
}

extern "C" {
    /// the port to connect to via proxy, used when making the options dictionary
    ///
    /// the port to connect to via proxy, used when making the options dictionary.  This parameter
    /// is optional and should not be passed normally.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odsessionproxyport?language=objc)
    pub static ODSessionProxyPort: Option<&'static NSString>;
}

extern "C" {
    /// the username to connect with via proxy, used when making the options dictionary
    ///
    /// the username to connect with via proxy, used when making the options dictionary
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odsessionproxyusername?language=objc)
    pub static ODSessionProxyUsername: Option<&'static NSString>;
}

extern "C" {
    /// the password to connect with via proxy, used when making the options dictionary
    ///
    /// the password to connect with via proxy, used when making the options dictionary
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odsessionproxypassword?language=objc)
    pub static ODSessionProxyPassword: Option<&'static NSString>;
}

extern_class!(
    /// Class for working with OpenDirectory sessions.
    ///
    /// Class for working with OpenDirectory sessions.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/opendirectory/odsession?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct ODSession;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for ODSession {}
);

impl ODSession {
    extern_methods!(
        /// Returns a shared instance of a local ODSession
        ///
        /// Returns a shared instance of a local ODSession.  This can be used for most situations unless
        /// more control is needed over the session.
        #[unsafe(method(defaultSession))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultSession() -> Option<Retained<ODSession>>;

        /// Creates an autoreleased instance of ODSession directed over Proxy to another host
        ///
        /// Creates an autoreleased instance of ODSession directed over Proxy to another host.  nil
        /// can be passed for no options. outError is optional parameter, nil can be passed if error
        /// details are not needed.  Options include:
        ///
        /// If proxy is required then a dictionary with keys should be:
        /// Key                             Value
        /// ODSessionProxyAddress        NSString(hostname or IP)
        /// ODSessionProxyPort           NSNumber(IP port, should not be set as it will default)
        /// ODSessionProxyUsername       NSString(username)
        /// ODSessionProxyPassword       NSString(password)
        ///
        /// # Safety
        ///
        /// - `in_options` generic should be of the correct type.
        /// - `in_options` might not allow `None`.
        /// - `out_error` might not allow `None`.
        #[unsafe(method(sessionWithOptions:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sessionWithOptions_error(
            in_options: Option<&NSDictionary>,
            out_error: Option<&mut Option<Retained<NSError>>>,
        ) -> Option<Retained<Self>>;

        /// Creates an instance of ODSession directed over Proxy to another host
        ///
        /// Creates an instance of ODSession directed over Proxy to another host.  nil can be
        /// passed for no options. outError is optional parameter, nil can be passed if error
        /// details are not needed. Options include:
        ///
        /// If proxy is required then a dictionary with keys should be:
        /// Key                             Value
        /// ODSessionProxyAddress        NSString(hostname or IP)
        /// ODSessionProxyPort           NSNumber(IP port, should not be set as it will default)
        /// ODSessionProxyUsername       NSString(username)
        /// ODSessionProxyPassword       NSString(password)
        ///
        /// # Safety
        ///
        /// - `in_options` generic should be of the correct type.
        /// - `in_options` might not allow `None`.
        /// - `out_error` might not allow `None`.
        #[unsafe(method(initWithOptions:error:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithOptions_error(
            this: Allocated<Self>,
            in_options: Option<&NSDictionary>,
            out_error: Option<&mut Option<Retained<NSError>>>,
        ) -> Option<Retained<Self>>;

        /// Returns the node names that are registered on this ODSession
        ///
        /// Returns the node names that are registered on this ODSession.  outError can be nil if
        /// error details are not needed.
        ///
        /// # Safety
        ///
        /// `out_error` might not allow `None`.
        #[unsafe(method(nodeNamesAndReturnError:))]
        #[unsafe(method_family = none)]
        pub unsafe fn nodeNamesAndReturnError(
            &self,
            out_error: Option<&mut Option<Retained<NSError>>>,
        ) -> Option<Retained<NSArray>>;

        /// Returns a list of names as NSStrings for all available configuration templates.
        ///
        ///
        /// Returns a list of names as NSStrings for all available configuration templates.  Configuration templates
        /// have pre-configured modules and/or mappings.  Useful for re-using existing configurations
        /// that may change with operating system without changing the actual configuration.
        #[unsafe(method(configurationTemplateNames))]
        #[unsafe(method_family = none)]
        pub unsafe fn configurationTemplateNames(&self) -> Retained<NSArray>;

        /// Returns a list names as NSStrings for all available mapping templates.
        ///
        ///
        /// Returns a list names as NSStrings for all available mapping templates.  Mapping templates have pre-configured
        /// record/attribute mappings.  Useful if a configuration uses a common layout of mappings for a type of server.
        #[unsafe(method(mappingTemplateNames))]
        #[unsafe(method_family = none)]
        pub unsafe fn mappingTemplateNames(&self) -> Retained<NSArray>;

        #[cfg(feature = "objc2-security-foundation")]
        /// Returns an authorization appropriate for managing configurations.
        ///
        ///
        /// Returns an authorization appropriate for managing configurations.  If a proxy session is in use this method will return
        /// nil and no error.
        ///
        /// # Safety
        ///
        /// `error` might not allow `None`.
        #[unsafe(method(configurationAuthorizationAllowingUserInteraction:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn configurationAuthorizationAllowingUserInteraction_error(
            &self,
            allow_interaction: bool,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> Option<Retained<SFAuthorization>>;

        #[cfg(feature = "ODConfiguration")]
        /// Reads the configuration for a given nodename.
        ///
        ///
        /// Reads the configuration for a given nodename.
        ///
        /// # Safety
        ///
        /// `nodename` might not allow `None`.
        #[unsafe(method(configurationForNodename:))]
        #[unsafe(method_family = none)]
        pub unsafe fn configurationForNodename(
            &self,
            nodename: Option<&NSString>,
        ) -> Option<Retained<ODConfiguration>>;

        #[cfg(all(feature = "ODConfiguration", feature = "objc2-security-foundation"))]
        /// Adds a new configuration to the existing ODSession.
        ///
        ///
        /// Adds a new configuration to the existing ODSession.  An SFAuthorization can be provided if necessary.
        ///
        /// # Safety
        ///
        /// - `configuration` might not allow `None`.
        /// - `authorization` might not allow `None`.
        /// - `error` might not allow `None`.
        #[unsafe(method(addConfiguration:authorization:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addConfiguration_authorization_error(
            &self,
            configuration: Option<&ODConfiguration>,
            authorization: Option<&SFAuthorization>,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> bool;

        #[cfg(all(feature = "ODConfiguration", feature = "objc2-security-foundation"))]
        /// Deletes an existing configuration from the ODSession.
        ///
        ///
        /// Deletes an existing configuration from the ODSession.  An authorization can be provided if necessary.
        ///
        /// # Safety
        ///
        /// - `configuration` might not allow `None`.
        /// - `authorization` might not allow `None`.
        /// - `error` might not allow `None`.
        #[unsafe(method(deleteConfiguration:authorization:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn deleteConfiguration_authorization_error(
            &self,
            configuration: Option<&ODConfiguration>,
            authorization: Option<&SFAuthorization>,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> bool;

        #[cfg(feature = "objc2-security-foundation")]
        /// Deletes an existing configuration from the ODSession.
        ///
        ///
        /// Deletes an existing configuration from the ODSession.  An authorization can be provided if necessary.
        ///
        /// # Safety
        ///
        /// - `nodename` might not allow `None`.
        /// - `authorization` might not allow `None`.
        /// - `error` might not allow `None`.
        #[unsafe(method(deleteConfigurationWithNodename:authorization:error:))]
        #[unsafe(method_family = none)]
        pub unsafe fn deleteConfigurationWithNodename_authorization_error(
            &self,
            nodename: Option<&NSString>,
            authorization: Option<&SFAuthorization>,
            error: Option<&mut Option<Retained<NSError>>>,
        ) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl ODSession {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}