Example #1
0
 internal Application(ApplicationDescriptor descriptor)
 {
     Name        = descriptor.name;
     ID          = descriptor.id;
     URL         = descriptor.url;
     APIName     = descriptor.api_name;
     Description = descriptor.description;
 }
Example #2
0
        internal ApplicationDescriptor AsApplicationDescriptor()
        {
            var descriptor = new ApplicationDescriptor()
            {
                name        = Name,
                id          = ID,
                api_name    = APIName,
                description = Description
            };

            return(descriptor);
        }
Example #3
0
        public Application Create(string name)
        {
            if (Session.Disconnected)
            {
                Session.Reconnect();
            }

            var descriptor = new ApplicationDescriptor()
            {
                name     = name,
                api_name = name
            };

            var request = Session.GetSessionRequest("/rest/system/app", Method.POST);

            request.JsonSerializer.ContentType = "application/json; charset=utf-8";
            request.JsonSerializer.Options     = new SerializerOptions()
            {
                SkipNullProperties = true
            };
            request.AddBody(descriptor);

            var response = Session.Client.Execute(request);

            switch (response.StatusCode)
            {
            case HttpStatusCode.Created:
            case HttpStatusCode.OK:
                return(Find(name));

            case HttpStatusCode.Forbidden:
            case HttpStatusCode.Unauthorized:
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                Session.Disconnected = true;

                throw DreamFactoryException.Parse(response);

            default:
                throw DreamFactoryException.Parse(response);
            }
        }