WS-RESTRICTED_API Host [RESTRICTED_API] : D5290-staging

<back to all web services

url_shortener

URL Shortener
The following routes are available for this service:
GET,POST/url_shortener
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class url_shortenerResponse:
    tiny_url: Optional[str] = None
    original_url: Optional[str] = None
    created_date: datetime.datetime = datetime.datetime(1, 1, 1)
    expiry_date: Optional[datetime.datetime] = None
    collision: Optional[int] = None


class operationType(str, Enum):
    NO_OPERATION = '0x4E71'
    SHORTEN_URL = 'ShortenUrl'
    GET_ORIGINAL_URL = 'GetOriginalUrl'
    REDIRECT_URL = 'RedirectUrl'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class url_shortener:
    # @ApiMember(DataType="string", Description="operation type", IsRequired=true, Name="operation", ParameterType="body")
    operation: Optional[operationType] = None
    """
    operation type
    """


    # @ApiMember(DataType="string", Description="url", IsRequired=true, Name="url", ParameterType="body")
    url: Optional[str] = None
    """
    url
    """


    # @ApiMember(DataType="string", Description="days to expire", Name="days", ParameterType="body")
    days: Optional[float] = None
    """
    days to expire
    """

Python url_shortener DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /url_shortener HTTP/1.1 
Host: milliet.io 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"operation":"0x4E71","url":"String","days":0}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"tiny_url":"String","original_url":"String","created_date":"0001-01-01T00:00:00.0000000","expiry_date":"0001-01-01T00:00:00.0000000","collision":0}