Skip to content

Commit

Permalink
cleanup for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Cozowicz committed Jun 8, 2024
1 parent 7e42396 commit f6a7f30
Show file tree
Hide file tree
Showing 62 changed files with 9,307 additions and 5,590 deletions.
4 changes: 3 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ pandas==2.0.3
azure-identity==1.7.1
azure-keyvault-secrets
azure-storage-file-datalake==12.3.1
azure-storage-blob>=12.9.0
azure-storage-blob>=12.9.0
anytree
IPython
409 changes: 243 additions & 166 deletions sempy_labs/AI.py

Large diffs are not rendered by default.

212 changes: 139 additions & 73 deletions sempy_labs/Connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@
import pandas as pd
from typing import List, Optional, Union

def create_connection_cloud(name: str, server_name: str, database_name: str, user_name: str, password: str, privacy_level: str):

#https://review.learn.microsoft.com/en-us/rest/api/fabric/core/connections/create-connection?branch=features%2Fdmts&tabs=HTTP

df = pd.DataFrame(columns=['Connection ID', 'Connection Name', 'Connectivity Type', 'Connection Type', 'Connection Path', 'Privacy Level', 'Credential Type', 'Single Sign On Type', 'Connection Encryption', 'Skip Test Connection'])
def create_connection_cloud(
name: str,
server_name: str,
database_name: str,
user_name: str,
password: str,
privacy_level: str,
):

# https://review.learn.microsoft.com/en-us/rest/api/fabric/core/connections/create-connection?branch=features%2Fdmts&tabs=HTTP

df = pd.DataFrame(
columns=[
"Connection ID",
"Connection Name",
"Connectivity Type",
"Connection Type",
"Connection Path",
"Privacy Level",
"Credential Type",
"Single Sign On Type",
"Connection Encryption",
"Skip Test Connection",
]
)

client = fabric.FabricRestClient()

Expand All @@ -17,49 +38,72 @@ def create_connection_cloud(name: str, server_name: str, database_name: str, use
"connectionDetails": {
"type": "SQL",
"parameters": [
{
"name": "server",
"value": server_name
},
{
"name": "database",
"value": database_name
}
]
{"name": "server", "value": server_name},
{"name": "database", "value": database_name},
],
},
"privacyLevel": privacy_level,
"credentialDetails": {
"singleSignOnType": "None",
"connectionEncryption": "NotEncrypted",
"skipTestConnection": False,
"credentials": {
"credentialType": "Basic",
"username": user_name,
"password": password
}
}
"credentialType": "Basic",
"username": user_name,
"password": password,
},
},
}

response = client.post(f"/v1/connections",json=request_body)
response = client.post(f"/v1/connections", json=request_body)

if response.status_code == 200:
o = response.json()
new_data = {'Connection Id': o['id'], 'Connection Name': o['name'], 'Connectivity Type': o['connectivityType'],
'Connection Type': o['connectionDetails']['type'], 'Connection Path': o['connectionDetails']['path'], 'Privacy Level': o['privacyLevel'],
'Credential Type': o['credentialDetails']['credentialType'], 'Single Sign On Type': o['credentialDetails']['singleSignOnType'],
'Connection Encryption': o['credentialDetails']['connectionEncryption'], 'Skip Test Connection': o['credentialDetails']['skipTestConnection']
new_data = {
"Connection Id": o["id"],
"Connection Name": o["name"],
"Connectivity Type": o["connectivityType"],
"Connection Type": o["connectionDetails"]["type"],
"Connection Path": o["connectionDetails"]["path"],
"Privacy Level": o["privacyLevel"],
"Credential Type": o["credentialDetails"]["credentialType"],
"Single Sign On Type": o["credentialDetails"]["singleSignOnType"],
"Connection Encryption": o["credentialDetails"]["connectionEncryption"],
"Skip Test Connection": o["credentialDetails"]["skipTestConnection"],
}
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)

df['Skip Test Connection'] = df['Skip Test Connection'].astype(bool)
df["Skip Test Connection"] = df["Skip Test Connection"].astype(bool)

return df
else:
print(response.status_code)

def create_connection_on_prem(name: str, gateway_id: str, server_name: str, database_name: str, credentials: str, privacy_level: str):

df = pd.DataFrame(columns=['Connection ID', 'Connection Name', 'Gateway ID', 'Connectivity Type', 'Connection Type', 'Connection Path', 'Privacy Level', 'Credential Type', 'Single Sign On Type', 'Connection Encryption', 'Skip Test Connection'])
def create_connection_on_prem(
name: str,
gateway_id: str,
server_name: str,
database_name: str,
credentials: str,
privacy_level: str,
):

df = pd.DataFrame(
columns=[
"Connection ID",
"Connection Name",
"Gateway ID",
"Connectivity Type",
"Connection Type",
"Connection Path",
"Privacy Level",
"Credential Type",
"Single Sign On Type",
"Connection Encryption",
"Skip Test Connection",
]
)

client = fabric.FabricRestClient()

Expand All @@ -70,53 +114,73 @@ def create_connection_on_prem(name: str, gateway_id: str, server_name: str, data
"connectionDetails": {
"type": "SQL",
"parameters": [
{
"name": "server",
"value": server_name
},
{
"name": "database",
"value": database_name
}
]
{"name": "server", "value": server_name},
{"name": "database", "value": database_name},
],
},
"privacyLevel": privacy_level,
"credentialDetails": {
"singleSignOnType": "None",
"connectionEncryption": "NotEncrypted",
"skipTestConnection": False,
"credentials": {
"credentialType": "Windows",
"values": [
{
"gatewayId": gateway_id,
"credentials": credentials
}
]
}
}
"credentialType": "Windows",
"values": [{"gatewayId": gateway_id, "credentials": credentials}],
},
},
}

response = client.post(f"/v1/connections",json=request_body)
response = client.post(f"/v1/connections", json=request_body)

if response.status_code == 200:
o = response.json()
new_data = {'Connection Id': o['id'], 'Connection Name': o['name'], 'Gateway ID': o['gatewayId'], 'Connectivity Type': o['connectivityType'],
'Connection Type': o['connectionDetails']['type'], 'Connection Path': o['connectionDetails']['path'], 'Privacy Level': o['privacyLevel'],
'Credential Type': o['credentialDetails']['credentialType'], 'Single Sign On Type': o['credentialDetails']['singleSignOnType'],
'Connection Encryption': o['credentialDetails']['connectionEncryption'], 'Skip Test Connection': o['credentialDetails']['skipTestConnection']
new_data = {
"Connection Id": o["id"],
"Connection Name": o["name"],
"Gateway ID": o["gatewayId"],
"Connectivity Type": o["connectivityType"],
"Connection Type": o["connectionDetails"]["type"],
"Connection Path": o["connectionDetails"]["path"],
"Privacy Level": o["privacyLevel"],
"Credential Type": o["credentialDetails"]["credentialType"],
"Single Sign On Type": o["credentialDetails"]["singleSignOnType"],
"Connection Encryption": o["credentialDetails"]["connectionEncryption"],
"Skip Test Connection": o["credentialDetails"]["skipTestConnection"],
}
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)

df['Skip Test Connection'] = df['Skip Test Connection'].astype(bool)
df["Skip Test Connection"] = df["Skip Test Connection"].astype(bool)

return df
else:
print(response.status_code)

def create_connection_vnet(name: str, gateway_id: str, server_name: str, database_name: str, user_name: str, password: str, privacy_level: str):

df = pd.DataFrame(columns=['Connection ID', 'Connection Name', 'Gateway ID', 'Connectivity Type', 'Connection Type', 'Connection Path', 'Privacy Level', 'Credential Type', 'Single Sign On Type', 'Connection Encryption', 'Skip Test Connection'])
def create_connection_vnet(
name: str,
gateway_id: str,
server_name: str,
database_name: str,
user_name: str,
password: str,
privacy_level: str,
):

df = pd.DataFrame(
columns=[
"Connection ID",
"Connection Name",
"Gateway ID",
"Connectivity Type",
"Connection Type",
"Connection Path",
"Privacy Level",
"Credential Type",
"Single Sign On Type",
"Connection Encryption",
"Skip Test Connection",
]
)

client = fabric.FabricRestClient()

Expand All @@ -127,42 +191,44 @@ def create_connection_vnet(name: str, gateway_id: str, server_name: str, databas
"connectionDetails": {
"type": "SQL",
"parameters": [
{
"name": "server",
"value": server_name
},
{
"name": "database",
"value": database_name
}
]
{"name": "server", "value": server_name},
{"name": "database", "value": database_name},
],
},
"privacyLevel": privacy_level,
"credentialDetails": {
"singleSignOnType": "None",
"connectionEncryption": "Encrypted",
"skipTestConnection": False,
"credentials": {
"credentialType": "Basic",
"username": user_name,
"password": password
}
}
"credentialType": "Basic",
"username": user_name,
"password": password,
},
},
}

response = client.post(f"/v1/connections",json=request_body)
response = client.post(f"/v1/connections", json=request_body)

if response.status_code == 200:
o = response.json()
new_data = {'Connection Id': o['id'], 'Connection Name': o['name'], 'Gateway ID': o['gatewayId'], 'Connectivity Type': o['connectivityType'],
'Connection Type': o['connectionDetails']['type'], 'Connection Path': o['connectionDetails']['path'], 'Privacy Level': o['privacyLevel'],
'Credential Type': o['credentialDetails']['credentialType'], 'Single Sign On Type': o['credentialDetails']['singleSignOnType'],
'Connection Encryption': o['credentialDetails']['connectionEncryption'], 'Skip Test Connection': o['credentialDetails']['skipTestConnection']
new_data = {
"Connection Id": o["id"],
"Connection Name": o["name"],
"Gateway ID": o["gatewayId"],
"Connectivity Type": o["connectivityType"],
"Connection Type": o["connectionDetails"]["type"],
"Connection Path": o["connectionDetails"]["path"],
"Privacy Level": o["privacyLevel"],
"Credential Type": o["credentialDetails"]["credentialType"],
"Single Sign On Type": o["credentialDetails"]["singleSignOnType"],
"Connection Encryption": o["credentialDetails"]["connectionEncryption"],
"Skip Test Connection": o["credentialDetails"]["skipTestConnection"],
}
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)

df['Skip Test Connection'] = df['Skip Test Connection'].astype(bool)
df["Skip Test Connection"] = df["Skip Test Connection"].astype(bool)

return df
else:
print(response.status_code)
print(response.status_code)
Loading

0 comments on commit f6a7f30

Please sign in to comment.