Skip to content

Commit

Permalink
Merge branch 'main' into schloerke/gut_api_files
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Dec 17, 2024
2 parents 00c10d7 + dbafa68 commit 2c49eed
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 88 deletions.
4 changes: 2 additions & 2 deletions src/posit/connect/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from .context import Context


class BundleMetadata(resources.Resource):
class BundleMetadata(resources.BaseResource):
pass


class Bundle(resources.Resource):
class Bundle(resources.BaseResource):
@property
def metadata(self) -> BundleMetadata:
return BundleMetadata(self._ctx, **self.get("metadata", {}))
Expand Down
10 changes: 5 additions & 5 deletions src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .oauth.associations import ContentItemAssociations
from .permissions import Permissions
from .repository import ContentItemRepositoryMixin
from .resources import Active, Resource, Resources, _ResourceSequence
from .resources import Active, BaseResource, Resources, _ResourceSequence
from .tags import ContentItemTags
from .vanities import VanityMixin
from .variants import Variants
Expand All @@ -42,7 +42,7 @@ def _assert_guid(guid: str):
assert len(guid) > 0, "Expected 'guid' to be non-empty"


class ContentItemOAuth(Resource):
class ContentItemOAuth(BaseResource):
def __init__(self, ctx: Context, content_guid: str) -> None:
super().__init__(ctx)
self["content_guid"] = content_guid
Expand All @@ -52,11 +52,11 @@ def associations(self) -> ContentItemAssociations:
return ContentItemAssociations(self._ctx, content_guid=self["content_guid"])


class ContentItemOwner(Resource):
class ContentItemOwner(BaseResource):
pass


class ContentItem(Active, ContentItemRepositoryMixin, VanityMixin, Resource):
class ContentItem(Active, ContentItemRepositoryMixin, VanityMixin, BaseResource):
class _AttrsBase(TypedDict, total=False):
# # `name` will be set by other _Attrs classes
# name: str
Expand Down Expand Up @@ -228,7 +228,7 @@ def restart(self) -> None:
f"Restart not supported for this application mode: {self['app_mode']}. Did you need to use the 'render()' method instead? Note that some application modes do not support 'render()' or 'restart()'.",
)

def update(
def update( # type: ignore[reportIncompatibleMethodOverride]
self,
**attrs: Unpack[ContentItem._Attrs],
) -> None:
Expand Down
19 changes: 5 additions & 14 deletions src/posit/connect/environments.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
from __future__ import annotations

from abc import abstractmethod
from collections.abc import Mapping, Sized
from typing import Protocol

from typing_extensions import (
Any,
List,
Literal,
Protocol,
SupportsIndex,
TypedDict,
overload,
runtime_checkable,
)

from .resources import Resource, ResourceSequence

MatchingType = Literal["any", "exact", "none"]
"""Directions for how environments are considered for selection.
Expand All @@ -40,7 +38,7 @@ class Installations(TypedDict):
"""Interpreter installations in an execution environment."""


class Environment(Mapping[str, Any]):
class Environment(Resource):
@abstractmethod
def destroy(self) -> None:
"""Destroy the environment.
Expand Down Expand Up @@ -95,13 +93,7 @@ def update(


@runtime_checkable
class Environments(Sized, Protocol):
@overload
def __getitem__(self, index: SupportsIndex) -> Environment: ...

@overload
def __getitem__(self, index: slice) -> List[Environment]: ...

class Environments(ResourceSequence[Environment], Protocol):
def create(
self,
*,
Expand Down Expand Up @@ -217,4 +209,3 @@ def find_by(
----
This action requires administrator or publisher privileges.
"""
...
4 changes: 2 additions & 2 deletions src/posit/connect/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TYPE_CHECKING, List, Optional, overload

from .paginator import Paginator
from .resources import Resource, Resources
from .resources import BaseResource, Resources

if TYPE_CHECKING:
import requests
Expand All @@ -14,7 +14,7 @@
from .users import User


class Group(Resource):
class Group(BaseResource):
def __init__(self, ctx: Context, **kwargs) -> None:
super().__init__(ctx, **kwargs)
self._ctx: Context = ctx
Expand Down
19 changes: 4 additions & 15 deletions src/posit/connect/jobs.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from __future__ import annotations

from abc import abstractmethod
from collections.abc import Mapping, Sized
from typing import (
Any,
Iterable,
List,
Literal,
Protocol,
SupportsIndex,
overload,
runtime_checkable,
)

from .resources import Resource, ResourceSequence

JobTag = Literal[
"unknown",
"build_report",
Expand Down Expand Up @@ -43,8 +39,7 @@
StatusCode = Literal[0, 1, 2]


class Job(Mapping[str, Any]):
@abstractmethod
class Job(Resource, Protocol):
def destroy(self) -> None:
"""Destroy the job.
Expand All @@ -59,13 +54,7 @@ def destroy(self) -> None:


@runtime_checkable
class Jobs(Sized, Protocol):
@overload
def __getitem__(self, index: SupportsIndex) -> Job: ...

@overload
def __getitem__(self, index: slice) -> List[Job]: ...

class Jobs(ResourceSequence[Job], Protocol):
def fetch(self) -> Iterable[Job]:
"""Fetch all jobs.
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/metrics/shiny_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import List, overload

from ..cursors import CursorPaginator
from ..resources import Resource, Resources
from ..resources import BaseResource, Resources


class ShinyUsageEvent(Resource):
class ShinyUsageEvent(BaseResource):
@property
def content_guid(self) -> str:
"""The associated unique content identifier.
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/metrics/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from . import shiny_usage, visits


class UsageEvent(resources.Resource):
class UsageEvent(resources.BaseResource):
@staticmethod
def from_event(
event: visits.VisitEvent | shiny_usage.ShinyUsageEvent,
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/metrics/visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import List, overload

from ..cursors import CursorPaginator
from ..resources import Resource, Resources
from ..resources import BaseResource, Resources


class VisitEvent(Resource):
class VisitEvent(BaseResource):
@property
def content_guid(self) -> str:
"""The associated unique content identifier.
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/oauth/associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import List

from ..context import Context
from ..resources import Resource, Resources
from ..resources import BaseResource, Resources


class Association(Resource):
class Association(BaseResource):
pass


Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/oauth/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from typing import List, Optional, overload

from ..resources import Resource, Resources
from ..resources import BaseResource, Resources
from .associations import IntegrationAssociations


class Integration(Resource):
class Integration(BaseResource):
"""OAuth integration resource."""

@property
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/oauth/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from typing import List, Optional, overload

from ..resources import Resource, Resources
from ..resources import BaseResource, Resources


class Session(Resource):
class Session(BaseResource):
"""OAuth session resource."""

def delete(self) -> None:
Expand Down
27 changes: 6 additions & 21 deletions src/posit/connect/packages.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
from __future__ import annotations

from typing_extensions import (
Any,
Iterable,
Literal,
Mapping,
Protocol,
Sized,
SupportsIndex,
overload,
)


class ContentPackage(Mapping[str, Any]):
pass
from .resources import Resource, ResourceSequence


class ContentPackages(Sized, Protocol):
@overload
def __getitem__(self, index: SupportsIndex) -> ContentPackage: ...
class ContentPackage(Resource, Protocol):
pass

@overload
def __getitem__(self, index: slice) -> ContentPackage: ...

class ContentPackages(ResourceSequence[ContentPackage], Protocol):
def fetch(
self,
*,
Expand Down Expand Up @@ -84,17 +75,11 @@ def find_by(
...


class Package(Mapping[str, Any]):
class Package(Resource, Protocol):
pass


class Packages(Sized, Protocol):
@overload
def __getitem__(self, index: SupportsIndex) -> ContentPackage: ...

@overload
def __getitem__(self, index: slice) -> ContentPackage: ...

class Packages(ResourceSequence[Package], Protocol):
def fetch(
self,
*,
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

from requests.sessions import Session as Session

from .resources import Resource, Resources
from .resources import BaseResource, Resources

if TYPE_CHECKING:
from .context import Context
from .groups import Group
from .users import User


class Permission(Resource):
class Permission(BaseResource):
def destroy(self) -> None:
"""Destroy the permission."""
path = f"v1/content/{self['content_guid']}/permissions/{self['id']}"
Expand Down
Loading

0 comments on commit 2c49eed

Please sign in to comment.