Skip to content

Commit

Permalink
Merge pull request #58 from datastax/feature/#57-user-agent-header
Browse files Browse the repository at this point in the history
Add user agent string to outgoing requests
  • Loading branch information
clun committed Oct 28, 2023
2 parents f99adc6 + a720532 commit 23fc15a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions astrapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "0.5.0"
6 changes: 5 additions & 1 deletion astrapy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import re

from astrapy import __version__
from astrapy.defaults import DEFAULT_TIMEOUT

logger = logging.getLogger(__name__)
Expand All @@ -15,6 +16,9 @@ class http_methods:
DELETE = "DELETE"


package_name = __name__.split(".")[0]


def make_request(
base_url,
auth_header,
Expand All @@ -31,7 +35,7 @@ def make_request(
params=url_params,
json=json_data,
timeout=DEFAULT_TIMEOUT,
headers={auth_header: token},
headers={auth_header: token, "User-Agent": f"{package_name}/{__version__}"},
)

return r
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from setuptools import setup
from os import path

from astrapy import __version__

this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()
Expand All @@ -25,7 +27,7 @@
"astrapy",
"astrapy/endpoints",
],
version="0.5.0",
version=__version__,
license="Apache license 2.0",
description="AstraPy is a Pythonic SDK for DataStax Astra",
long_description=long_description,
Expand Down

0 comments on commit 23fc15a

Please sign in to comment.