示例#1
0
 public ApiVersion(string baseUrl, string status, string id)
 {
     Status   = status;
     Id       = id;
     _baseUrl = baseUrl;
     Updated  = DateTime.UtcNow.ToString("s");
     Links    = new RestLink[]
     {
         new RestLink(
             String.Format("{0}{1}/", _baseUrl, Constants.CurrentApiVersion), RestLink.Self),
     };
 }
示例#2
0
 public Flavor()
 {
     Links = new RestLink[] {
         new RestLink("http://openstack.example.com/openstack/flavors/1", RestLink.Bookmark)
     };
 }
示例#3
0
        /// <summary>
        ///     Creates a RestItem object for testing purposes as
        ///     it was returned by the UDAPI service
        /// </summary>
        /// <param name="properties"></param>
        /// <returns></returns>
        private static RestItem GetRestItem(Dictionary <string, string> properties)
        {
            string id    = properties.ContainsKey("id") ? properties["id"] : "UnknownResourceId";
            string sport = properties.ContainsKey("sport") ? properties["sport"] : "Football";


            // RestItem as returned by the UDAPI service
            RestItem item = new RestItem {
                Name    = properties.ContainsKey("name") ? properties["name"] : "UnknownResource",
                Content = new Summary {
                    Id          = id,
                    MatchStatus = properties.ContainsKey("matchstatus") ? Convert.ToInt32(properties["matchstatus"]) : 40,
                    Sequence    = properties.ContainsKey("sequence") ? Convert.ToInt32(properties["sequence"]) : 1,
                    StartTime   = properties.ContainsKey("starttime") ? properties["starttime"] : DateTime.UtcNow.ToString(),
                    Tags        = new List <Tag>
                    {
                        new Tag
                        {
                            Id    = 2,
                            Key   = "Competition",
                            Value = properties.ContainsKey("competition") ? properties["competition"] : "UnknownCompetition"
                        },
                        new Tag
                        {
                            Id    = 1,
                            Key   = "Participant",
                            Value = properties.ContainsKey("participant2") ? properties["participant2"] : "UnknownAwayParticipant"
                        },
                        new Tag
                        {
                            Id    = 0,
                            Key   = "Participant",
                            Value = properties.ContainsKey("participant1") ? properties["participant1"] : "UnknownHomeParticipant"
                        }
                    }
                },

                Links = new List <RestLink>(),
            };

            // links to the resource services
            var restlink = new RestLink {
                Relation = "http://api.sportingsolutions.com/rels/snapshot",
                Href     = string.Format("http://apicui.sportingsolutions.com/UnifiedDataAPI/snapshot/{0}/{1}/fake-random-token-0", sport, id),
                Verbs    = new[] { "GET" }
            };

            item.Links.Add(restlink);

            restlink = new RestLink {
                Relation = "http://api.sportingsolutions.com/rels/stream/amqp",
                Href     = string.Format("http://apicui.sportingsolutions.com/UnifiedDataAPI/strean/{0}/{1}/fake-random-token-1", sport, id),
                Verbs    = new[] { "GET" }
            };
            item.Links.Add(restlink);

            restlink = new RestLink {
                Relation = "http://api.sportingsolutions.com/rels/sequence",
                Href     = string.Format("http://apicui.sportingsolutions.com/UnifiedDataAPI/sequence/{0}/{1}/fake-random-token-2", sport, id),
                Verbs    = new[] { "GET" }
            };
            item.Links.Add(restlink);

            restlink = new RestLink {
                Relation = "http://api.sportingsolutions.com/rels/stream/echo",
                Href     = "http://apicui.sportingsolutions.com/EchoRestService/echo/fake-random-token-3",
                Verbs    = new[] { "POST" }
            };
            item.Links.Add(restlink);

            restlink = new RestLink {
                Relation = "http://api.sportingsolutions.com/rels/stream/batchecho",
                Href     = "http://apicui.sportingsolutions.com/EchoRestService/batchecho/fake-random-token-4",
                Verbs    = new[] { "POST" }
            };
            item.Links.Add(restlink);

            return(item);
        }