Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
918eaf4
Added patch functionality to call an UPSERT to the salesforce rest api
Oct 11, 2019
cc6bb52
Merge pull request #1 from acv-auctions/add_patch_def
ajrabey Oct 24, 2019
470c0df
Set version so we can curate this library separately in Artifactory
jrbudnack Oct 24, 2019
a57bacf
Add CICD goodies.
jrbudnack Oct 24, 2019
e4b0b4a
Add Dockerfile for building the library
jrbudnack Oct 24, 2019
557d4e6
Oops
jrbudnack Oct 24, 2019
0a1e2ea
More additions for building/deploying
jrbudnack Oct 24, 2019
7a0881a
Add patch method for the Tooling API client
jrbudnack Apr 21, 2021
f3e8fdb
Merge pull request #2 from acv-auctions/tooling_patch
jrbudnack Apr 21, 2021
17d7c40
Fix version
jrbudnack Apr 21, 2021
8a0c670
Fix version
jrbudnack Apr 21, 2021
33086af
Fix Jenkinsfile and nexus deploy
jrbudnack Apr 21, 2021
8763b16
Fix version
jrbudnack Apr 21, 2021
4d1694e
If PATCH comes back null, do not try to json parse it
jrbudnack Apr 22, 2021
080d3df
Merge branch 'master' into release-acv
jrbudnack Apr 22, 2021
2598db5
Better parsing of response object in case just text is null
jrbudnack Apr 22, 2021
396dbe0
Merge branch 'master' into release-acv
jrbudnack Apr 22, 2021
fec6f78
Use 'is not none' to properly test for null for the response object f…
jrbudnack Apr 22, 2021
15c47d6
Merge branch 'master' into release-acv
jrbudnack Apr 22, 2021
ee31704
PATCH seems to not be consistent in returning JSON, so making the lib…
jrbudnack Apr 30, 2021
20d9b4c
adding apexrest option
ajrabey Jun 24, 2021
5da7d9f
Merge pull request #3 from acv-auctions/apexrest_uri
ajrabey Jun 24, 2021
f980b0d
adding version
ajrabey Jun 24, 2021
6941cbb
Merge pull request #4 from acv-auctions/release-06-21-acv
ajrabey Jun 24, 2021
99ab273
adding func to call apexrest api
ajrabey Jun 24, 2021
9928e4c
Merge branch 'release-acv' into adding-apexrest-func
ajrabey Jun 24, 2021
f11e3fa
version update
ajrabey Jun 24, 2021
58d7821
Merge branch 'adding-apexrest-func' of https://github.com/acv-auction…
ajrabey Jun 24, 2021
0cef52a
Merge pull request #5 from acv-auctions/adding-apexrest-func
ajrabey Jun 24, 2021
d56f914
adding -acv
ajrabey Jun 25, 2021
517c454
Merge branch 'release-acv' into adding-apexrest-func
ajrabey Jun 25, 2021
629f104
Merge pull request #6 from acv-auctions/adding-apexrest-func
ajrabey Jun 25, 2021
89d9324
Removing version
ajrabey Jun 25, 2021
eaa5d76
Merge branch 'release-acv' into adding-apexrest-func
ajrabey Jun 25, 2021
ff545ae
Merge pull request #7 from acv-auctions/adding-apexrest-func
ajrabey Jun 25, 2021
7db446d
Updating default api version to 53.0
cantowski Feb 16, 2022
92d1b23
Updating version in setup.py
cantowski Feb 16, 2022
54d6b99
Created CODEOWNERS
cantowski Feb 16, 2022
18ac04c
Updating CODEOWNERS group
cantowski Feb 16, 2022
c87493d
Merge pull request #8 from acv-auctions/new-version
cantowski Feb 17, 2022
02f9b29
Updating package name
cantowski Feb 15, 2023
718a3dc
Merge pull request #10 from acv-auctions/SI-1227
cantowski Feb 15, 2023
4993372
version bump
ajrabey Aug 1, 2023
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: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# These owners will be the default owners for everything in the repo.
* @acv-auctions/Salesforce-Infrastructure
8 changes: 8 additions & 0 deletions .pypirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[distutils]
index-servers =
nexus

[nexus]
repository: https://nexus.infra.acvauctions.com/repository/pypi-releases/
username:
password:
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM python:3.7.3-alpine3.9

RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk && apk add --no-cache gcc bash musl-dev libffi-dev \
openssl-dev build-base git

RUN mkdir -p /opt/sfdclib
WORKDIR /opt/sfdclib
RUN pip install --user pipenv
ENV PATH="/root/.local/bin:${PATH}"

ARG NEXUS_USER
ENV NEXUS_USER=$NEXUS_USER

ARG NEXUS_PASSWORD
ENV NEXUS_PASSWORD=$NEXUS_PASSWORD

RUN pipenv lock
RUN pipenv sync --dev

ARG VERSION
ENV APP_VERSION=$VERSION

COPY sfdclib /opt/sfdclib/sfdclib
COPY .pypirc /root/.pypirc
COPY run.sh /opt/sfdclib/run.sh
COPY setup.py /opt/sfdclib/setup.py
COPY README.* /opt/sfdclib/

ENV APP_MODE=$APP_MODE
CMD ["sh", "-c", "./run.sh"]
31 changes: 31 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@Library('acv-jenkins-lib')
import com.acvJenkins.*;

pipeline {
agent {
kubernetes {
defaultContainer 'docker'
yaml new GlobalVars().runnerPod()
}
}
environment {
NEXUS_CREDS = credentials('NEXUS_CREDS')
NEXUS_USER = "${NEXUS_CREDS_USR}"
NEXUS_PASSWORD = "${NEXUS_CREDS_PSW}"
}
stages {
stage('Publish') {
when {
expression { env.BRANCH_NAME.endsWith('-acv') }
}
steps {
sh 'make deploy'
}
}
}
post {
always {
sh 'make --ignore-errors stop-ci'
}
}
}
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CONTAINER_NAME := acv-sfdc-ci
VERSION := $(shell git fetch --tags && git describe --tags)

.PHONY: clean
clean:
find . -type f -name '.DS_Store' -delete -o -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete

.PHONY: deps
deps:
pipenv install
pipenv install --dev

build: clean
git submodule update --init --recursive
@docker build \
--build-arg NEXUS_USER=${NEXUS_USER} \
--build-arg NEXUS_PASSWORD=${NEXUS_PASSWORD} \
--build-arg VERSION=${VERSION} \
--tag $(CONTAINER_NAME):$(VERSION) .

.PHONY: deploy
deploy: build
docker run \
-e APP_MODE=deploy \
-e NEXUS_USER=${NEXUS_USER} \
-e NEXUS_PASSWORD=${NEXUS_PASSWORD} \
-v /var/run/docker.sock:/var/run/docker.sock \
$(CONTAINER_NAME):$(VERSION)

.PHONY: stop-ci
stop-ci:
docker ps -a -q --filter ancestor=$(CONTAINER_NAME):$(VERSION) | xargs docker rm -f
docker ps -a -q --filter ancestor=mysql:5.7git s | xargs docker rm -f
13 changes: 13 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[ -z "$APP_MODE" ] && APP_MODE="test"

sed -i'.old' 's/username:/username: '$(echo $NEXUS_USER)'/g' /root/.pypirc
sed -i'.old' 's/password:/password: '$(echo $NEXUS_PASSWORD)'/g' /root/.pypirc
sed -i'.old' 's/\%40/\@/g' /root/.pypirc

if [ $APP_MODE = "deploy" ]; then
cat /root/.pypirc
python setup.py sdist upload -r nexus
EXIT_CODE=$?
fi

exit $EXIT_CODE
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from setuptools import setup

setup(
name='sfdclib',
version='0.2.26',
name='sfdclib-acv',
version='0.2.26.12',
author='Andrey Shevtsov',
author_email='ashevtsov@rbauction.com',
packages=['sfdclib'],
Expand Down
11 changes: 11 additions & 0 deletions sfdclib/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ class SfdcRestApi:
""" Class to work with Salesforce REST API """
_API_BASE_URI = "/services/data/v{version}"
_SOQL_QUERY_URI = "/query/?{query}"
_API_APEXREST_URI = "/services/apexrest"

def __init__(self, session):
if not session.is_connected():
raise Exception("Session must be connected prior to instantiating this class")
self._session = session

def _get_apexrest_api_uri(self):
"""Returns APEXREST API base URI without the version for this connection"""
return self._API_APEXREST_URI

def _get_api_uri(self):
""" Returns REST API base URI for this connection """
return self._API_BASE_URI.format(**{'version': self._session.get_api_version()})
Expand Down Expand Up @@ -46,6 +51,12 @@ def post(self, uri, data):
response = self._session.post(url, headers=self._get_headers(), json=data)
return self._parse_get_post_response(response)

def patch(self, uri, data):
"""" HTTP PATCH request"""
url = self._session.construct_url(self._get_api_uri() + uri)
response = self._session.patch(url, headers=self._get_headers(), json=data)
return self._parse_get_post_response(response)

def delete(self, uri):
""" HTTP DELETE request """
try:
Expand Down
2 changes: 1 addition & 1 deletion sfdclib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class SfdcSession(Session):
_DEFAULT_API_VERSION = "37.0"
_DEFAULT_API_VERSION = "53.0"
_LOGIN_URL = "https://{instance}.salesforce.com"
_SOAP_API_BASE_URI = "/services/Soap/c/{version}"
_XML_NAMESPACES = {
Expand Down
11 changes: 11 additions & 0 deletions sfdclib/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def post(self, uri, data):
response = self._session.post(url, headers=self._get_headers(), data=data)
return self._parse_get_post_response(response)

def patch(self, uri, data):
''' HTTP PATCH request '''
url = self._session.construct_url(self._get_tooling_api_uri() + uri)
response = self._session.patch(url, headers=self._get_headers(), json=data)
# Since we can't rely on Salesforce to give us a good JSON response on these PATCH requests, just wrap in
# a try except and hope for the best...
try:
return self._parse_get_post_response(response)
except Exception:
return response

def delete(self, uri):
''' HTTP DELETE request '''
try:
Expand Down