Here's an example I had put together in a different context. It sets up a single IRIS instance with a WebGateway and IAM. It also sets up TLS on the IAM instance.
apiVersion: intersystems.com/v1alpha1
kind: IrisCluster
metadata:
name: fhir-iam
spec:
imagePullSecrets:
- name: icr-secret
storageClassName: gp2
licenseKeySecret:
name: fhir-iris-key-secret
configSource:
name: fhir-iris-cpf
tls:
iam:
secret:
secretName: fhir-iam-tls
topology:
iam:
image: containers.intersystems.com/intersystems/iam:3.0.2.0-4
webgateway:
image: containers.intersystems.com/intersystems/webgateway:2022.1.0.209.0
type: apache
replicas: 1
applicationPaths:
- /csp/sys
- /myfhirserver
- /csp/healthshare
alternativeServers: LoadBalancing
data:
image: containers.intersystems.com/intersystems/irishealth:2022.1.0.209.0
serviceTemplate:
spec:
type: ClusterIPThanks for sharing answer.
Adding a snippet for %ZSTART in case fellow community person wished find / refer to later.
#include %occStatus quit 0 SYSTEM() PUBLIC { Try { // Some test to determine whether to start or not if ##class(%File).Exists("c:\tmp\stop.txt") { Do INT^SHUTDOWN } } Catch { } quit 0 }
Here's the code to create task to purge messages in all interoperability namespaces:
set sc = ##class(%SYS.Namespace).ListAll(.result)
kill result("%SYS"), result("HSCUSTOM"), result("HSLIB"), result("HSSYS"), result("REPO")
while 1 {set ns = $o(result($g(ns))) quit:ns="" continue:$e(ns,1,2)="^^" set $namespace = ns continue:'##class(%Dictionary.ClassDefinition).%ExistsId("Ens.MessageHeader") set task=##class(%SYS.Task).%New(),task.Name = "Purge old Interoperability data in " _ $namespace,task.NameSpace=$Namespace,task.TimePeriod=0,task.TimePeriodEvery=1,task.DailyFrequency=0,task.DailyFrequencyTime="",task.DailyIncrement="",task.DailyStartTime = 3600,task.DailyEndTime = "",task.StartDate = $p($H,",",1)+1,task.Priority = 2,task.Expires = 0,taskdef = ##class(Ens.Util.Tasks.Purge).%New(),taskdef.BodiesToo = 1,taskdef.KeepIntegrity = 1,taskdef.NumberOfDaysToKeep = 1,taskdef.TypesToPurge = "all",sc = task.AssignSettings(taskdef),task.TaskClass=$classname(taskdef),sc = task.%Save()}You can also use the $ROLES special variable to do that. It contains both the user's assigned roles and any roles you've added during the process. You can't change the user roles, but if you set it that will add a role. So you could do:
set $ROLES = "%All"
Or whatever role you need to add, then do the stuff that requires that roles, then do:
set $ROLES = ""
That will take away the %All role you added, reverting the process to just the user's normal roles.
Here a simple python test used :
import iris
import ssl
import getpass
import os
def main():
connection_string = "k8s-092c0f86-acbb1223-47d44444fb-7667ad082a377a9e.elb.us-east-1.amazonaws.com:443/USER"
try:
username = os.environ['CLOUDLOGIN']
except:
username = getpass.getpass('Login:')
try:
password = os.environ['CLOUDPASSWORD']
except:
password = getpass.getpass('Password:')
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.verify_mode=ssl.CERT_REQUIRED
context.check_hostname = False
context.load_verify_locations("certificateSQLaaS.pem")
connection = iris.connect(connection_string, username, password, sslcontext=context)
print("connected")
tablename = "data.movie"
cursor = connection.cursor()
try:
cursor.execute("DROP TABLE "+tablename)
print(tablename+" dropped succesfully")
except InterfaceError as err:
print(f"Unexpected {err=}")
except Exception as err:
print("ERROR WHILE DROPPING TABLE "+tablename)
print(f"Unexpected {err=}, {type(err)=}")
try:
cursor.execute("CREATE TABLE "+tablename+" (title varchar(500), year int, score numeric)")
print(tablename+" created succesfully")
except Exception as err:
print("ERROR WHILE CREATING TABLE"+tablename)
print(f"Unexpected {err=}, {type(err)=}")
data = [
("Monty Python Live at the Hollywood Bowl", 1982, 7.9),
("Monty Python's The Meaning of Life", 1983, 7.5),
("Monty Python's Life of Brian", 1979, 8.0),
]
try:
cursor.executemany("INSERT INTO "+tablename+" VALUES(?, ?, ?)", data)
print("data succesfully inserted in "+tablename)
except Exception as err:
print("ERROR WHILE INSERTING DATA IN"+tablename)
print(f"Unexpected {err=}, {type(err)=}")
connection.commit()
connection.close()
print("disconnected")
if __name__ == "__main__":
main().png)
FYI, in your "Building SQL In Strings" section, you can also still use %SQL.Statement like this:
set stmt = ##class(%SQL.Statement).%New()
// Note the question mark in the query.
set query = "SELECT Name, Age FROM Patient WHERE ID=?"
set sc = stmt.%Prepare(query)
// You can add error handing here if the above status results in an error
// Providing variables to the %Execute method will insert them where the question marks are in the query, in order
set rs = stmt.%Execute(id)Thanks @David Hockenbroch!
I strongly discourage the use of embedded sql, it has many disadvantages. For complex queries you can use the following construct (a bit overkill for this example):
set query = 0
set args = 0
set query($Increment(query)) = "SELECT Name, Age"
set query($Increment(query)) = "FROM Patient"
set query($Increment(query)) = "WHERE Age >= ?"
set args($Increment(args)) = age
set result = ##class(%SQL.Statement).%ExecDirect(, .query, args...)
if result.%SQLCODE < 0
{
// Your error handling here
throw ##class(%Exception.SQL).CreateFromSQLCODE(result.%SQLCODE,result.%Message)
}
while result.%Next()
{
write result.Name," ",result.Age,!
}Introduction
The standard %Net.HttpRequest library in InterSystems IRIS is powerful and comprehensive, but it can be verbose for simple operations. Writing an HTTP request often requires several lines of code to instantiate the class, configure the server, the port, HTTPS, add headers, and finally send the request.
When testing in the terminal, this configuration quickly becomes too heavy, and usually ends up with the creation of temporary methods...
FastHTTP was designed to address this need. This utility class provides a fluent and concise interface to perform HTTP calls in a single line, while automatically handling the underlying complexity (SSL/TLS, URL parsing, JSON encoding, headers, etc.).
WIJ (write image journal) is used for data before it is saved to the database. This is used to keep the data consistency (block level in database) and avoid database degradation. If IRIS (or the OS) crash, WIJ will have "dirty blocks" (not written to databases) that will be weritten during the next IRIS startup.
Journal files (or mirror journal, in case you have mirroring) are used after data saved to the database. This will help for transactions rollback and also to ensure a good restore point up to the "current time" along with the latest backup restore.
The sequence is:
1. Read a block was changed from the database
2. Write the modified block to WIJ
3. Write the modified block to the database
4. Write the global SETS and KILLS (and also transaction start/stop) to the journal file
This is more for my memory that anything else but I thought I'd share it because it often comes up in comments, but is not in the InterSystems documentation.
There is a wonderful utility called ^REDEBUG that increases the level of logging going into mgr\cconsole.log.
You activate it by
a) start terminal/login
b) zn "%SYS"
c) do ^REDEBUG
d) change logging level to FFFFFFFF
if you are on you production system (with lots of traffic) I suggest you quickly reproduce the error, rename the cconsole.log file, and repeat the steps above to set the logging level to FF.
USER>:? :<number> Recall command # <number> :? Display help :py Do $system.Python.Shell() :mdx Do $system.DeepSee.Shell() :sql Do $system.SQL.Shell() :tsql Do $system.SQL.TSQLShell() :alias Create/display aliases :clear Clear history buffer :history Display command history :unalias Remove aliasesHTH