Skip to content

Commit

Permalink
Release 0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Oct 13, 2023
1 parent e41a0c0 commit d1ef4a1
Show file tree
Hide file tree
Showing 22 changed files with 252 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fern-api"
version = "0.0.9"
version = "0.0.10"
description = ""
readme = "README.md"
authors = []
Expand Down
2 changes: 1 addition & 1 deletion src/fern/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "fern-api",
"X-Fern-SDK-Version": "0.0.9",
"X-Fern-SDK-Version": "0.0.10",
}
headers["Authorization"] = f"Bearer {self._get_token()}"
return headers
Expand Down
22 changes: 20 additions & 2 deletions src/fern/resources/snippets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,35 @@
TypeScriptSdk,
TypeScriptSnippet,
)
from .errors import ApiIdNotFound, EndpointNotFound, SdkNotFound
from .resources import ApiId, commons
from .errors import (
ApiIdNotFound,
ApiIdRequiredError,
EndpointNotFound,
InvalidPageError,
OrgIdAndApiIdNotFound,
OrgIdNotFound,
OrgIdRequiredError,
SdkNotFound,
)
from .resources import ApiId, OrgId, UnauthorizedError, UnavailableError, UserNotInOrgError, commons

__all__ = [
"ApiId",
"ApiIdNotFound",
"ApiIdRequiredError",
"EndpointIdentifier",
"EndpointMethod",
"EndpointNotFound",
"EndpointPath",
"GoSdk",
"GoSnippet",
"InvalidPageError",
"JavaSdk",
"JavaSnippet",
"OrgId",
"OrgIdAndApiIdNotFound",
"OrgIdNotFound",
"OrgIdRequiredError",
"PythonSdk",
"PythonSnippet",
"Sdk",
Expand All @@ -56,5 +71,8 @@
"SnippetsPage",
"TypeScriptSdk",
"TypeScriptSnippet",
"UnauthorizedError",
"UnavailableError",
"UserNotInOrgError",
"commons",
]
137 changes: 127 additions & 10 deletions src/fern/resources/snippets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@
from ...core.jsonable_encoder import jsonable_encoder
from ...core.remove_none_from_dict import remove_none_from_dict
from .errors.api_id_not_found import ApiIdNotFound
from .errors.api_id_required_error import ApiIdRequiredError
from .errors.endpoint_not_found import EndpointNotFound
from .errors.invalid_page_error import InvalidPageError
from .errors.org_id_and_api_id_not_found import OrgIdAndApiIdNotFound
from .errors.org_id_not_found import OrgIdNotFound
from .errors.org_id_required_error import OrgIdRequiredError
from .errors.sdk_not_found import SdkNotFound
from .resources.commons.errors.unauthorized_error import UnauthorizedError
from .resources.commons.errors.unavailable_error import UnavailableError
from .resources.commons.errors.user_not_in_org_error import UserNotInOrgError
from .resources.commons.types.api_id import ApiId
from .resources.commons.types.org_id import OrgId
from .types.endpoint_identifier import EndpointIdentifier
from .types.sdk import Sdk
from .types.snippet import Snippet
Expand All @@ -33,6 +42,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper):
def get(
self,
*,
org_id: typing.Optional[OrgId] = OMIT,
api_id: typing.Optional[ApiId] = OMIT,
sdks: typing.Optional[typing.List[Sdk]] = OMIT,
endpoint: EndpointIdentifier,
Expand All @@ -41,6 +51,9 @@ def get(
Get snippet by endpoint method and path
Parameters:
- org_id: typing.Optional[OrgId]. If the same API is defined across multiple organization,
you must specify an organization ID.
- api_id: typing.Optional[ApiId]. If you have more than one API, you must specify its ID.
- sdks: typing.Optional[typing.List[Sdk]]. The SDKs for which to load snippets. If unspecified,
Expand All @@ -56,6 +69,8 @@ def get(
client.snippets.get(endpoint=EndpointIdentifier(method=EndpointMethod.GET, path="/v1/search"))
"""
_request: typing.Dict[str, typing.Any] = {"endpoint": endpoint}
if org_id is not OMIT:
_request["orgId"] = org_id
if api_id is not OMIT:
_request["apiId"] = api_id
if sdks is not OMIT:
Expand All @@ -74,36 +89,63 @@ def get(
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.List[Snippet], _response_json) # type: ignore
if "error" in _response_json:
if _response_json["error"] == "UnauthorizedError":
raise UnauthorizedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "UserNotInOrgError":
raise UserNotInOrgError()
if _response_json["error"] == "UnavailableError":
raise UnavailableError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdRequiredError":
raise ApiIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdRequiredError":
raise OrgIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdAndApiIdNotFound":
raise OrgIdAndApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdNotFound":
raise OrgIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdNotFound":
raise ApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "EndpointNotFound":
raise EndpointNotFound()
raise EndpointNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "SDKNotFound":
raise SdkNotFound()
if _response_json["error"] == "ApiIdNotFound":
raise ApiIdNotFound()
raise SdkNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

def load(
self,
*,
page: typing.Optional[int] = None,
org_id: typing.Optional[OrgId] = OMIT,
api_id: typing.Optional[ApiId] = OMIT,
sdks: typing.Optional[typing.List[Sdk]] = OMIT,
) -> SnippetsPage:
"""
Parameters:
- page: typing.Optional[int].
- org_id: typing.Optional[OrgId]. If the same API is defined across multiple organization,
you must specify an organization ID.
- api_id: typing.Optional[ApiId]. If you have more than one API, you must specify its ID.
- sdks: typing.Optional[typing.List[Sdk]]. The SDKs for which to load snippets. If unspecified,
snippets for the latest published SDKs will be returned.
---
from fern.client import Fern
from fern import PythonSdk, Sdk_Python
client = Fern(token="YOUR_TOKEN")
client.snippets.load()
client.snippets.load(
page=1,
org_id="vellum",
api_id="vellum-ai",
sdks=[Sdk_Python(value=PythonSdk(package="vellum-ai", version="1.2.1"))],
)
"""
_request: typing.Dict[str, typing.Any] = {}
if org_id is not OMIT:
_request["orgId"] = org_id
if api_id is not OMIT:
_request["apiId"] = api_id
if sdks is not OMIT:
Expand All @@ -122,6 +164,27 @@ def load(
raise ApiError(status_code=_response.status_code, body=_response.text)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(SnippetsPage, _response_json) # type: ignore
if "error" in _response_json:
if _response_json["error"] == "UnauthorizedError":
raise UnauthorizedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "UserNotInOrgError":
raise UserNotInOrgError()
if _response_json["error"] == "UnavailableError":
raise UnavailableError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "InvalidPageError":
raise InvalidPageError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdRequiredError":
raise ApiIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdRequiredError":
raise OrgIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdAndApiIdNotFound":
raise OrgIdAndApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdNotFound":
raise OrgIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdNotFound":
raise ApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "SDKNotFound":
raise SdkNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)


Expand All @@ -132,6 +195,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper):
async def get(
self,
*,
org_id: typing.Optional[OrgId] = OMIT,
api_id: typing.Optional[ApiId] = OMIT,
sdks: typing.Optional[typing.List[Sdk]] = OMIT,
endpoint: EndpointIdentifier,
Expand All @@ -140,6 +204,9 @@ async def get(
Get snippet by endpoint method and path
Parameters:
- org_id: typing.Optional[OrgId]. If the same API is defined across multiple organization,
you must specify an organization ID.
- api_id: typing.Optional[ApiId]. If you have more than one API, you must specify its ID.
- sdks: typing.Optional[typing.List[Sdk]]. The SDKs for which to load snippets. If unspecified,
Expand All @@ -155,6 +222,8 @@ async def get(
await client.snippets.get(endpoint=EndpointIdentifier(method=EndpointMethod.GET, path="/v1/search"))
"""
_request: typing.Dict[str, typing.Any] = {"endpoint": endpoint}
if org_id is not OMIT:
_request["orgId"] = org_id
if api_id is not OMIT:
_request["apiId"] = api_id
if sdks is not OMIT:
Expand All @@ -173,36 +242,63 @@ async def get(
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.List[Snippet], _response_json) # type: ignore
if "error" in _response_json:
if _response_json["error"] == "UnauthorizedError":
raise UnauthorizedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "UserNotInOrgError":
raise UserNotInOrgError()
if _response_json["error"] == "UnavailableError":
raise UnavailableError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdRequiredError":
raise ApiIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdRequiredError":
raise OrgIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdAndApiIdNotFound":
raise OrgIdAndApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdNotFound":
raise OrgIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdNotFound":
raise ApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "EndpointNotFound":
raise EndpointNotFound()
raise EndpointNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "SDKNotFound":
raise SdkNotFound()
if _response_json["error"] == "ApiIdNotFound":
raise ApiIdNotFound()
raise SdkNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

async def load(
self,
*,
page: typing.Optional[int] = None,
org_id: typing.Optional[OrgId] = OMIT,
api_id: typing.Optional[ApiId] = OMIT,
sdks: typing.Optional[typing.List[Sdk]] = OMIT,
) -> SnippetsPage:
"""
Parameters:
- page: typing.Optional[int].
- org_id: typing.Optional[OrgId]. If the same API is defined across multiple organization,
you must specify an organization ID.
- api_id: typing.Optional[ApiId]. If you have more than one API, you must specify its ID.
- sdks: typing.Optional[typing.List[Sdk]]. The SDKs for which to load snippets. If unspecified,
snippets for the latest published SDKs will be returned.
---
from fern.client import AsyncFern
from fern import PythonSdk, Sdk_Python
client = AsyncFern(token="YOUR_TOKEN")
await client.snippets.load()
await client.snippets.load(
page=1,
org_id="vellum",
api_id="vellum-ai",
sdks=[Sdk_Python(value=PythonSdk(package="vellum-ai", version="1.2.1"))],
)
"""
_request: typing.Dict[str, typing.Any] = {}
if org_id is not OMIT:
_request["orgId"] = org_id
if api_id is not OMIT:
_request["apiId"] = api_id
if sdks is not OMIT:
Expand All @@ -221,4 +317,25 @@ async def load(
raise ApiError(status_code=_response.status_code, body=_response.text)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(SnippetsPage, _response_json) # type: ignore
if "error" in _response_json:
if _response_json["error"] == "UnauthorizedError":
raise UnauthorizedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "UserNotInOrgError":
raise UserNotInOrgError()
if _response_json["error"] == "UnavailableError":
raise UnavailableError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "InvalidPageError":
raise InvalidPageError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdRequiredError":
raise ApiIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdRequiredError":
raise OrgIdRequiredError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdAndApiIdNotFound":
raise OrgIdAndApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "OrgIdNotFound":
raise OrgIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "ApiIdNotFound":
raise ApiIdNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["error"] == "SDKNotFound":
raise SdkNotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)
16 changes: 15 additions & 1 deletion src/fern/resources/snippets/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# This file was auto-generated by Fern from our API Definition.

from .api_id_not_found import ApiIdNotFound
from .api_id_required_error import ApiIdRequiredError
from .endpoint_not_found import EndpointNotFound
from .invalid_page_error import InvalidPageError
from .org_id_and_api_id_not_found import OrgIdAndApiIdNotFound
from .org_id_not_found import OrgIdNotFound
from .org_id_required_error import OrgIdRequiredError
from .sdk_not_found import SdkNotFound

__all__ = ["ApiIdNotFound", "EndpointNotFound", "SdkNotFound"]
__all__ = [
"ApiIdNotFound",
"ApiIdRequiredError",
"EndpointNotFound",
"InvalidPageError",
"OrgIdAndApiIdNotFound",
"OrgIdNotFound",
"OrgIdRequiredError",
"SdkNotFound",
]
4 changes: 2 additions & 2 deletions src/fern/resources/snippets/errors/api_id_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


class ApiIdNotFound(ApiError):
def __init__(self) -> None:
super().__init__(status_code=404)
def __init__(self, body: str):
super().__init__(status_code=404, body=body)
8 changes: 8 additions & 0 deletions src/fern/resources/snippets/errors/api_id_required_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was auto-generated by Fern from our API Definition.

from ....core.api_error import ApiError


class ApiIdRequiredError(ApiError):
def __init__(self, body: str):
super().__init__(status_code=400, body=body)
4 changes: 2 additions & 2 deletions src/fern/resources/snippets/errors/endpoint_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


class EndpointNotFound(ApiError):
def __init__(self) -> None:
super().__init__(status_code=404)
def __init__(self, body: str):
super().__init__(status_code=404, body=body)
8 changes: 8 additions & 0 deletions src/fern/resources/snippets/errors/invalid_page_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was auto-generated by Fern from our API Definition.

from ....core.api_error import ApiError


class InvalidPageError(ApiError):
def __init__(self, body: str):
super().__init__(status_code=400, body=body)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was auto-generated by Fern from our API Definition.

from ....core.api_error import ApiError


class OrgIdAndApiIdNotFound(ApiError):
def __init__(self, body: str):
super().__init__(status_code=400, body=body)
Loading

0 comments on commit d1ef4a1

Please sign in to comment.