Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CURRENT_YEAR ?= $(shell date +%Y)
# Quarto settings
QUARTO ?= quarto
# quartodoc doesn't like py3.8; Run using `--with` as it can conflict with the project's dependencies
QUARTODOC ?= --with "quartodoc==0.8.1" quartodoc
QUARTODOC ?= --no-cache --with "quartodoc==0.8.1" quartodoc

# Netlify settings
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
Expand Down
21 changes: 15 additions & 6 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,29 @@ quartodoc:
- put
- patch
- delete
- title: Posit Connect Resources
- title: Resources
contents:
- connect.bundles
- connect.content
- connect.env
- connect.environments
- connect.groups
- connect.jobs
- connect.metrics
- connect.metrics.usage
- connect.oauth
- connect.oauth.associations
- connect.oauth.integrations
- connect.oauth.sessions
- connect.packages
- connect.permissions
- connect.repository
- connect.system
- connect.tags
- connect.tasks
- connect.users
- connect.vanities
- title: Posit Connect Metrics
contents:
- connect.metrics
- connect.metrics.usage
- title: External Integrations
- title: Third-Party Integrations
contents:
- connect.external.databricks
- connect.external.snowflake
156 changes: 84 additions & 72 deletions src/posit/connect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from .content import Content
from .context import Context, ContextManager, requires
from .groups import Groups
from .metrics import Metrics
from .oauth import OAuth
from .metrics.metrics import Metrics
from .oauth.oauth import OAuth
from .resources import _PaginatedResourceSequence, _ResourceSequence
from .system import System
from .tags import Tags
Expand Down Expand Up @@ -44,18 +44,30 @@ class Client(ContextManager):
----------
content: Content
Content resource.
environments: Environments
Environments resource.
groups: Groups
Groups resource.
me: User
Connect user resource.
Current user resource.
metrics: Metrics
Metrics resource.
oauth: OAuth
OAuth resource.
packages: Packages
Packages resource.
system: System
System resource.
tags: Tags
Tags resource.
tasks: Tasks
Tasks resource.
users: Users
Users resource.
vanities: Vanities
Vanities resource.
version: str
Server version.
The server version.
"""

@overload
Expand Down Expand Up @@ -163,28 +175,21 @@ def __init__(self, *args, **kwargs) -> None:
self._ctx = Context(self)

@property
def version(self) -> str | None:
def content(self) -> Content:
"""
The server version.
The content resource interface.

Returns
-------
str
The version of the Posit Connect server.
Content
The content resource instance.
"""
return self._ctx.version
return Content(self._ctx)

@property
def me(self) -> User:
"""
The connected user.

Returns
-------
User
The currently authenticated user.
"""
return me.get(self._ctx)
@requires(version="2023.05.0")
def environments(self) -> Environments:
return _ResourceSequence(self._ctx, "v1/environments")

@property
def groups(self) -> Groups:
Expand All @@ -198,40 +203,66 @@ def groups(self) -> Groups:
return Groups(self._ctx)

@property
def tasks(self) -> Tasks:
def me(self) -> User:
"""
The tasks resource interface.
The connected user.

Returns
-------
tasks.Tasks
The tasks resource instance.
User
The currently authenticated user.
"""
return Tasks(self._ctx)
return me.get(self._ctx)

@property
def users(self) -> Users:
def metrics(self) -> Metrics:
"""
The users resource interface.
The Metrics API interface.

The Metrics API is designed for capturing, retrieving, and managing
quantitative measurements of Connect interactions. It is commonly used
for monitoring and analyzing system performance, user behavior, and
business processes. This API facilitates real-time data collection and
accessibility, enabling organizations to make informed decisions based
on key performance indicators (KPIs).

Returns
-------
Users
The users resource instance.
Metrics
The metrics API instance.

Examples
--------
>>> from posit import connect
>>> client = connect.Client()
>>> content_guid = "2243770d-ace0-4782-87f9-fe2aeca14fc8"
>>> events = client.metrics.usage.find(content_guid=content_guid)
>>> len(events)
24
"""
return Users(self._ctx)
return Metrics(self._ctx)

@property
def content(self) -> Content:
@requires(version="2024.08.0")
def oauth(self) -> OAuth:
"""
The content resource interface.
The OAuth API interface.

Returns
-------
Content
The content resource instance.
OAuth
The oauth API instance.
"""
return Content(self._ctx)
return OAuth(self._ctx, self.cfg.api_key)

@property
@requires(version="2024.11.0")
def packages(self) -> Packages:
return _PaginatedResourceSequence(self._ctx, "v1/packages", uid="name")

@property
def system(self) -> System:
return System(self._ctx, "v1/system")

@property
def tags(self) -> Tags:
Expand All @@ -256,63 +287,44 @@ def tags(self) -> Tags:
return Tags(self._ctx, "v1/tags")

@property
def metrics(self) -> Metrics:
def tasks(self) -> Tasks:
"""
The Metrics API interface.

The Metrics API is designed for capturing, retrieving, and managing
quantitative measurements of Connect interactions. It is commonly used
for monitoring and analyzing system performance, user behavior, and
business processes. This API facilitates real-time data collection and
accessibility, enabling organizations to make informed decisions based
on key performance indicators (KPIs).
The tasks resource interface.

Returns
-------
Metrics
The metrics API instance.

Examples
--------
>>> from posit import connect
>>> client = connect.Client()
>>> content_guid = "2243770d-ace0-4782-87f9-fe2aeca14fc8"
>>> events = client.metrics.usage.find(content_guid=content_guid)
>>> len(events)
24
tasks.Tasks
The tasks resource instance.
"""
return Metrics(self._ctx)
return Tasks(self._ctx)

@property
@requires(version="2024.08.0")
def oauth(self) -> OAuth:
def users(self) -> Users:
"""
The OAuth API interface.
The users resource interface.

Returns
-------
OAuth
The oauth API instance.
Users
The users resource instance.
"""
return OAuth(self._ctx, self.cfg.api_key)

@property
@requires(version="2024.11.0")
def packages(self) -> Packages:
return _PaginatedResourceSequence(self._ctx, "v1/packages", uid="name")
return Users(self._ctx)

@property
def vanities(self) -> Vanities:
return Vanities(self._ctx)

@property
def system(self) -> System:
return System(self._ctx, "v1/system")
def version(self) -> str | None:
"""
The server version.

@property
@requires(version="2023.05.0")
def environments(self) -> Environments:
return _ResourceSequence(self._ctx, "v1/environments")
Returns
-------
str
The version of the Posit Connect server.
"""
return self._ctx.version

def __del__(self):
"""Close the session when the Client instance is deleted."""
Expand Down
2 changes: 2 additions & 0 deletions src/posit/connect/env.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Environment variable resources."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Iterator, List, Mapping, MutableMapping, Optional
Expand Down
2 changes: 2 additions & 0 deletions src/posit/connect/environments.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Environment resources."""

from __future__ import annotations

from abc import abstractmethod
Expand Down
7 changes: 6 additions & 1 deletion src/posit/connect/external/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# NOTE: The APIs in this module are provided as a convenience and are subject to breaking changes.
"""External integrations.

Notes
-----
The APIs in this module are provided as a convenience and are subject to breaking changes.
"""
7 changes: 5 additions & 2 deletions src/posit/connect/external/databricks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""
"""Databricks SDK integration.

Databricks SDK credentials implementations which support interacting with Posit OAuth integrations on Connect.

NOTE: These APIs are provided as a convenience and are subject to breaking changes:
Notes
-----
These APIs are provided as a convenience and are subject to breaking changes:
https://github.com/databricks/databricks-sdk-py#interface-stability
"""

Expand Down
8 changes: 6 additions & 2 deletions src/posit/connect/external/snowflake.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""Snowflake SDK credentials implementations which support interacting with Posit OAuth integrations on Connect.
"""Snowflake SDK integration.

NOTE: The APIs in this module are provided as a convenience and are subject to breaking changes.
Snowflake SDK credentials implementations which support interacting with Posit OAuth integrations on Connect.

Notes
-----
The APIs in this module are provided as a convenience and are subject to breaking changes.
"""

from typing import Optional
Expand Down
2 changes: 2 additions & 0 deletions src/posit/connect/jobs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Job resources."""

from __future__ import annotations

from typing import (
Expand Down
2 changes: 2 additions & 0 deletions src/posit/connect/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Metric resources."""

from .metrics import Metrics as Metrics
2 changes: 2 additions & 0 deletions src/posit/connect/oauth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""OAuth resources."""

from .oauth import Credentials as Credentials
from .oauth import OAuth as OAuth
2 changes: 2 additions & 0 deletions src/posit/connect/packages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Package resources."""

from __future__ import annotations

from typing_extensions import (
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Content item repository."""
"""Repository resources."""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""System Information."""
"""System resources."""

from __future__ import annotations

Expand Down
2 changes: 2 additions & 0 deletions src/posit/connect/tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Tag resources."""

from __future__ import annotations

from abc import ABC, abstractmethod
Expand Down
2 changes: 2 additions & 0 deletions src/posit/connect/vanities.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Vanity URL resources."""

from typing import Callable, List, Optional

from typing_extensions import NotRequired, Required, TypedDict, Unpack
Expand Down
Loading