Ejemplo n.º 1
0
        public static void Main()
        {
            //Create api proxy
            API_Proxy_BackendConsole apiKrios = new API_Proxy_BackendConsole(API_Proxy_BackendConsole.BaseUrl_SandBox, "YOUR API KEY HERE");
            //Open event channel
            EventChannel evtChannel = new EventChannel(EventChannel.EventHubUrl_Sandbox);
            //Create a scope used in callback
            Scope evtScope = new Scope(evtChannel, apiKrios);

            #region Create Admin stff

            //Create a TenantKrios for the end user. You will be the manager of this tenant.
            TenantKrios tenant = new TenantKrios()
            {
                Company   = "SwissDesk X Test Krios 10",
                Firstname = "",
                Lastname  = ""
            };

            tenant.Create(apiKrios);

            //Sign agreement for this customer
            //tenant.SignAgreement(apiKrios, "SwissDesk X", "1.0.0");


            //Create a resource pool
            Pool p = new Pool()
            {
                IdCustomer = tenant.Id,
                IsDefault  = true,
                Title      = "DefaultPool"
            };

            p.Create(apiKrios);

            //Grant access on this pool for the end user and the manager (your own tenant)
            p.GrantAccess(apiKrios, UserADKomodo.OBJTYPE);
            p.GrantAccessToManager(apiKrios, UserADKomodo.OBJTYPE);

            p.GrantAccess(apiKrios, Storage.OBJTYPE);
            p.GrantAccessToManager(apiKrios, Storage.OBJTYPE);

            p.GrantAccess(apiKrios, StorageHeadFolder.OBJTYPE);
            p.GrantAccessToManager(apiKrios, StorageHeadFolder.OBJTYPE);

            p.GrantAccess(apiKrios, SDXProfile.OBJTYPE);
            p.GrantAccessToManager(apiKrios, SDXProfile.OBJTYPE);

            p.GrantAccess(apiKrios, SDXSession.OBJTYPE);
            p.GrantAccessToManager(apiKrios, SDXSession.OBJTYPE);

            p.GrantAccess(apiKrios, SDXService.OBJTYPE);
            p.GrantAccessToManager(apiKrios, SDXService.OBJTYPE);

            #endregion

            //Instantiate a UserADKomodo and put it in scope. This object will be create later.
            //Pwd policy: 8 chars, at least one special char (non-alphanumeric), a number or a uppercase letter.
            UserADKomodo user = new UserADKomodo(tenant.Id, p.Id, "apiTest1")
            {
                P_DisplayName = "User TestApi 1",
                P_Pwd         = "MyStrongPwd2!"
            };

            //Add some usefull variable in the scope
            evtScope.Add("user", user);
            evtScope.Add("pool", p);
            evtScope.Add("tenant", tenant);

            //Create the storage and wait util the creation is complete
            evtChannel.WaitOn(user.Create(apiKrios), evtScope, OnUserADKomodoCreated);

            while (working)
            {
                Thread.Sleep(5000);
            }
        }